in reply to Text::CSV_XS and blank lines
This may be a situation where you're forced to forgo the use of the convenience function, getline_hr, and roll your own code to generate a hash of the field values keyed by field labels. I do this a lot myself because I'm forced to use a version of Text::CSV_XS that predates the introduction of getline_hr.
my $value_of; $csv->parse(); @value_of{ @ordered_field_labels } = $csv->fields();
Typically, I get the ordered field labels from the CSV file header.
my @ordered_field_labels; while (my $csv_record = <>) { $csv->parse($csv_record); my @values = $csv->fields(); if ($INPUT_LINE_NUMBER == 1) { @ordered_field_labels = @values; # ... } # ... }
It's not inelegant. It's just a little less convenient.
(The blank lines are outside any quoted strings, right? They're not literal blank lines within fields are they?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Text::CSV_XS and blank lines
by constantreader (Initiate) on Feb 03, 2011 at 22:29 UTC | |
by Jim (Curate) on Feb 03, 2011 at 22:39 UTC | |
by constantreader (Initiate) on Feb 03, 2011 at 22:46 UTC | |
|
Re^2: Text::CSV_XS and blank lines
by Tux (Canon) on Feb 04, 2011 at 07:11 UTC |