in reply to Parsing a CSV file in a unique way
If that wasn't the case, I'd do something like (untested)
my $sep = ';'; # field separator my $expected_field_count = scalar split /$sep/, <>; # header line while(<>) { chomp; my @fields = split /$sep/, $_; while(@fields < $expected_field_count) { my $fieldline = <>; my @l = split /$sep/, $_; $fields[-1] .= '<br>'. shift @l; push(@fields,@l) if @l; } ... }
That works only if your csv has a fixed number of fields. BTW, there are CSV modules out there...
--shmem
_($_=" "x(1<<5)."?\n".q·/)Oo. G°\ /
/\_¯/(q /
---------------------------- \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Parsing a CSV file in a unique way
by herveus (Prior) on Oct 11, 2006 at 19:19 UTC | |
by shmem (Chancellor) on Oct 12, 2006 at 05:30 UTC |