in reply to Re^2: Need to sort comma delimited, double quoted file
in thread Need to sort comma delimited, double quoted file
That code would fail if *any* of the lines contains embedded newlines.
I'd simplify the code to this, assuming the header has no embedded newlines:
my $csv = Text::CSV_XS->new ({ binary => 1, decode_utf8 => 1, auto_diag => 1, allow_loose_quotes => 1, }); open my $data, "<:encoding(utf-8)", $file or die "$file: $!\n"; my $ref; my @header = $csv->header ($data); while (my $row = $csv->getline ($data)) { push @$ref, $row; }
In CSV don't let perl deal with the EOL. In Text::CSV and Text::CSV_XS the differences between Windows EOL and Linux EOL aur fully automatically dealt with within the definition of legal CSV.
I cannot tell anything about inappropriate ioctl calls regarding to CSV parsing. Neither on Linux nor on Windows. If the error is reproducable, I'd need the CSV file in full (preferably in a ZIP to ensure no binary conversions take place).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Need to sort comma delimited, double quoted file
by CSharma (Sexton) on Jul 28, 2017 at 04:19 UTC | |
|
Re^4: Need to sort comma delimited, double quoted file
by CSharma (Sexton) on Jul 27, 2017 at 08:13 UTC | |
by hippo (Archbishop) on Jul 27, 2017 at 08:42 UTC |