in reply to Help parsing a complicated csv
The parsing of the CSV data as such should not be too hard a problem. Just use Text::CSV_XS or Text::CSV. Now the only thing left to do is to come up with a criterium (or criteria) than make the headers stand out/be different from "normal" data.
my $csv = Text::CSV_XS->new ({ binary => 1, auto_diag => 1}); my @hdr; while (my $row = $csv->getline ($fh)) { # example: header lines start with A-Z, data doesn't if (!@hdr or $row->[0] =~ m/^[A-Z]/) { @hdr = @{$row}; next; } # just an example my %hash; @hash{@hdr} = @$row; }
|
|---|