What would be some example data, how it's currently being parsed, and how you'd like it to be parsed?
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] [Watch: Dir/Any] |
| [reply] [Watch: Dir/Any] [d/l] [select] |
There are, of course, going to be boundary cases that don't work as expected as soon as you start playing with allowing undoubled double-quotes inside of a format that expects them doubled. However Text::xSV allows you to define arbitrary filters that it preprocesses text with, and should do a reasonable job on the above with the following filter:
sub {
my $line = shift;
$line =~ s/\r$//;
$line =~ s/"(.)/""$1/g;
$line =~ s/"?,"?/,/g;
return $line;
}
Yes, there is some fragility, but it should be at least moderately hard to trigger. | [reply] [Watch: Dir/Any] [d/l] |
And, what should the parser do with the following:
"Smith","John",12/31/1962,"Author of "How to Break Programs" and other
+ books,"Bugger"
"Smith","John",12/31/1962,Author of "How to Break Programs" and other
+books,"Bugger"
"Smith","John",12/31/1962,'Author of "How to Break Programs" and other
+ books,"Bugger"
"Smith","John",12/31/1962,'Author of "How to Break Programs" and other
+ books',"Bugger"
------
We are the carpenters and bricklayers of the Information Age.
Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose
I shouldn't have to say this, but any code, unless otherwise stated, is untested
| [reply] [Watch: Dir/Any] [d/l] |