in reply to csv to flat-file
It just struck me that Perl already knows how to deal with csv data without needing any modules or clever regexes.
C:\test>type junk.txt 1, 1.2, -3000, fred, "bill & ben", "there's no business like show busi +ness", 'stuff, with, commas' C:\test>perl -ne "my @a; eval qq[\@a = ($_);];print qq[@a],$/" junk.tx +t 1 1.2 -3000 fred bill & ben there's no business like show business stu +ff, with, commas C:\test>
A list assignment is a very proficient parser for csv data.
Update:Having seen the update that you want the fields newline delimited, this should handle most forms of csv file.
C:\test>perl -ne "my @a; eval qq[\@a = ($_);];print $_, $/ for @a" jun +k.txt 1 1.2 -3000 fred bill & ben there's no business like show business stuff, with, commas C:\test>
Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: csv to flat-file
by diotalevi (Canon) on Nov 28, 2002 at 16:23 UTC | |
by BrowserUk (Patriarch) on Nov 28, 2002 at 18:00 UTC | |
by diotalevi (Canon) on Nov 28, 2002 at 18:28 UTC | |
by BrowserUk (Patriarch) on Nov 28, 2002 at 18:37 UTC |