in reply to Re: problems parsing CSV
in thread problems parsing CSV
#!/usr/bin/perl -- use strict; use warnings; use Text::CSV; use Data::Dump::Streamer; Main(@ARGV); exit(0); sub Main { #~ my $csv = Text::CSV->new ( { auto_diag => 1, } ); my $csv = Text::CSV->new ( { auto_diag => 1, allow_loose_quotes = +> 1, allow_loose_escapes => 1,} ); warn "012345678901234567890123456789\n", my $str = q!stuff,"more","foo (1994 "bar" only)",1234,1988,3.0,""! +; $csv->parse($str) and Dump([ $csv->fields ]); $csv->combine(qw' stuff more', 'foo (1994 "bar" only)', 1234, 1988 +,3.0,"") and warn $csv->string; } __END__ 012345678901234567890123456789 stuff,"more","foo (1994 "bar" only)",1234,1988,3.0,"" at temp.pl line +15. $ARRAY1 = [ 'stuff', 'more', 'foo (1994 "bar" only)', 1234, 1988, '3.0', '' ]; stuff,more,"foo (1994 ""bar"" only)",1234,1988,3, at temp.pl line 18.
|
|---|