Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
Max Field Lengths for Delimited File

New User

Jun 23, 2009, 12:01 PM

Views: 4044
Max Field Lengths for Delimited File

Hi - I am an intermediate / expert perl user and am about to write a program that fulfills the requirements below. However, before I start - I wanted to poll the perl experts out there to see if you know of an existing program or module that does this already. I've already spent a half day looking around to no avail. I want to create a file layout for a delimited file.

Take a delimited file (comma for simplicity) and output a result page that lists the field name and the maximum field length. There are variable number of fields (columns). There will be nothing in the csv changed or altered. The process should only analyze and output a newly created "file layout" that a client can use to create an optimally sized database or give correct information if they wanted to convert it to a fixed field file.

The program must run on *nix and we are talking 100 million record files and up.

File Example 1:

Expected Output 1:

File Example 2:

Expected Output 2:

It's pretty simple and I was hoping I wasn't the only person who needed such functionality. I'm tired of reinventing the wheel - so if anyone out there knows of a program they use or a module - I would appreciate it.

Thx -


Veteran / Moderator

Jun 23, 2009, 12:41 PM

Views: 4043
Re: [ejhansen71] Max Field Lengths for Delimited File

Nothing pre-written that I'm aware of, but your requirements would be very trivial to implement and I've seen this as a homework assignment for a Perl beginners class. My guess is that it would be about 25 lines.