in reply to Re: CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408
in thread CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408
By the way, the data originators paste lines and/or paragraphs from Word into a form that puts it into a proprietary data base within a program called DOORS. DOORS exported the db as a ',' separated csv file. The csv has under 9K rows with lots of embedded newlines, and non-ascii chars.
use Text::CSV; use UTF8BOM; use utf8; use Encode; use strict; my $origfile = 'csv.csv'; my $infile = 'csv_in.csv'; `cp -f $origfile $infile`; my $outfile = 'csv_out.csv'; my $in_fh; #`cp csv.csv $infile`; UTF8BOM->remove_from_file($infile); my @rows; my $csv = Text::CSV->new ( { binary => 1 } ) or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $in_fh, "<:encoding(utf8)", "$infile" or die (__LINE__.": \n") +; while ( my $row = $csv->getline( $in_fh ) ) { $row->[4] =~ m/Hardware/ or next; # Causes csv2xls.pl problems. push (@rows, ($row)); } $csv->eof or $csv->error_diag(); close $in_fh; $csv->eol ("\r\n"); my $csv_out; my $num_rows = @rows; print ("There are $num_rows rows\n"); open $csv_out, ">:encoding(utf8)", "$outfile" or die(__LINE__.": \n"); $csv->print ($csv_out, $_) for @rows; close $csv_out or die (__LINE__.": \n"); unlink("csv_out.xls"); `csv2xls.pl -u csv_out.csv`;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: CSV_XS ERROR: 2027 - EIQ - Quoted field not terminated @ pos 408
by graff (Chancellor) on May 22, 2010 at 14:13 UTC | |
by Anonymous Monk on May 22, 2010 at 16:42 UTC | |
by graff (Chancellor) on May 22, 2010 at 17:53 UTC | |
by FunkyMonk (Bishop) on May 22, 2010 at 22:36 UTC | |
by Anonymous Monk on May 22, 2010 at 16:45 UTC |