Subject: | CSV parser is broken by commas inside quotes |
If a comma occurs inside a quoted string in a CSV file, AnyData seems unable to read it:
$ cat > test.csv
"here","there is","a","simple","csv","file"
"a","b","c","d","e","f"
^d
$ # This can be read as you'd expect:
$ perl -e 'use AnyData;use Data::Dumper; $table = adTie("CSV", "test.csv"); foreach $key (keys %$table) {print $key." = ".Dumper($$table{$key})}'
HASH(0x81b395c) = $VAR1 = [
{
'here' => 'a',
'csv' => 'e',
'a' => 'c',
'simple' => 'd',
'file' => 'f',
'there is' => 'b'
}
];
$ cat > test.csv
"here","there, is","a","simple","csv","file"
"a","b","c","d","e","f"
^d
$ # But now we introduce a comma after 'there', and it all goes to pot:
$ perl -e 'use AnyData;use Data::Dumper; $table = adTie("CSV", "test.csv"); foreach $key (keys %$table) {print $key." = ".Dumper($$table{$key})}'
HASH(0x81b383c) = $VAR1 = [
{},
{}
];
HASH(0x81b38f0) = $VAR1 = [
{},
{}
];