[wellylug] curly csv formatting
David Antliff
dave.antliff at paradise.net.nz
Fri Jul 9 11:36:19 NZST 2004
On Fri, 9 Jul 2004, Mark Signal wrote:
> what I need to do is fill in the name/dob details on all the subsequent
> lines until it gets to the next new client details.
> Logic something like .. if the space between these 2 commas is empty then
> copy the details on the same space on the line above...
Could you set the 'record delimiter' ($/) such that it makes the file
easier to process? Then you can consider the problem as a collection of
'records' (one per client) rather than a collection of lines (several per
client).
Unfortunately Perl doesn't let you use a regular expression for $/ so
according to my Perl cookbook here, you can do this instead:
undef $/; # read in the ENTIRE file
@chunks = split(/pattern/, <FILEHANDLE>);
And now each element of the chunks array contains a record.
However if your file is really big, this might require a lot of memory and
time. Might be worth a try tho?
--
David.
More information about the wellylug
mailing list