Data conversion

Travis Roy travis at scootz.net
Wed Jan 8 13:05:44 EST 2003


> > 	Putting data out in a formatted setup is easy once you know the max
> length of the record.  I understand that you want to figure out the max
> length of each entry in each field and then add one - you can do this
> one of two ways.  Read the entire thing into memory (does not scale for
> large files) or iterate over the file twice and just mark the maximum
> length.  Anyone else have a better idea on how to find the max length of
> a field in a CSV file?

That is correct. It's easy to say each field is say 30 chars long, but
sometimes we get data that has fields that are 60 or even 80 and we need
the whole thing, other times we get a bunch of tiny ones that are only 1
or 2 and that just sucks up space (yes, space is that tight)

> #data is in 3 ordered arrays - get the real data in here..
> #this is just an example.
> my @first = ('first', 'names', 'here');
> my @last = ('last', 'names', 'here');
> my @emails = ('email', 'addresses', 'here');

Let me just add that it's not always 3 fields, it could be up to 30.
Naming them is not needed.



More information about the gnhlug-discuss mailing list