in reply to The future of Text::CSV_XS - TODO
News from the trenches: a new attribute strict_eol will be available in the next release:
my $csv = Text::CSV_XS->new ({ strict_eol => 1 }); $csv->strict_eol (0); my $f = $csv->strict_eol;
If this attribute is set to 0, no EOL consistency checks are done.
If this attribute is set to 1, any row that parses with a EOL other
than the EOL from the first row will cause a warning.
The error will be ignored
and parsing continues. This warning is only thrown once. Note that in data with
various different
line endings, \r\r will still throw an error that
cannot be ignored.
If this attribute is set to 2 or higher, any row that parses with a EOL
other than the EOL from the first row will cause
error 2016 to be thrown.
The line being parsed to this error might not be stored in the result.
Any feedback welcome ...
The function (method) csv () will use the warning level by default.
There are still some edge-cases that might need a change, but the basics have settled.
Als always, you can get a pre-release from github.
1,A,Ape\r\n 2,B,Bear\r\n 3,C,Canary\n <-- will warn with error 2016
Edge case example:
1,A,Ape\r\n 2,B,Bear\r\n 3,C,Canary\r\r\n <-- will warn with error 2016 but also might not ret +urn an empty row
The edge cases could also be considered "wrong" in all previous releases, and when strict_eol is disabled,
the behavior should be as before.
|
---|