[Boston.pm] Reading a variable CSV file with embeded newlines

2007-06-08 Thread Alex Brelsfoard
OK, so I thought we'd talked about something like this before, but I couldn't find it. I have a CSV file where each line may NOT have the same number of fields. One item per line. But occasionally a field in an item will have one or more newlines in it. How can I break this up correctly? Thanks.

Re: [Boston.pm] Reading a variable CSV file with embeded newlines

2007-06-08 Thread Gyepi SAM
On Fri, Jun 08, 2007 at 03:26:56PM -0400, Alex Brelsfoard wrote: > I have a CSV file where each line may NOT have the same number of fields. > One item per line. xSV is line oriented: as long as each line is well formed it should be parsed correctly. Making sense of the data may be more difficult

Re: [Boston.pm] Reading a variable CSV file with embeded newlines

2007-06-08 Thread Ben Tilly
On 6/8/07, Gyepi SAM <[EMAIL PROTECTED]> wrote: > On Fri, Jun 08, 2007 at 03:26:56PM -0400, Alex Brelsfoard wrote: > > I have a CSV file where each line may NOT have the same number of fields. > > One item per line. > > xSV is line oriented: as long as each line is well formed it should be parsed >

Re: [Boston.pm] Reading a variable CSV file with embeded newlines

2007-06-08 Thread Guillermo Roditi
i have run into this problem before here's my code foreach my $file (@$args){ #replace all newlines that are not imediately # surrounded by quotes with a space my $text = read_file( $file ) or die("Couldn't open $file for preprocessing"); $text =~ s/([^\"])\r?

Re: [Boston.pm] Reading a variable CSV file with embeded newlines

2007-06-08 Thread Guillermo Roditi
Oops. i went too fast. thats a preprocess command that i use with App::Cmd (highly recommended by the way) $args is an arrayref of filepaths read_file is provided by File::Slurp the regex is what you are looking for. The problem sucks since its a badly formatted file, but i normally just run that a