in reply to CSV file
The idea is to join previously split parts, if some part contains odd count of text delimiters. But, there is one big mistake. CSV field can contain EOL and in this case my code piece does not work.sub parseCSVrow { my ($row, $fdelim, $tdelim) = @_; chomp($row); my @ret = split(/$fdelim/,$row); my $i = 0; while($i < @ret) { if (($ret[$i] =~ s/$tdelim/$tdelim/ge) % 2) { if ($i + 1 == @ret) { die "ERROR: not ending text"; } else { $ret[$i] = $ret[$i].$fdelim.$ret[$i+1]; splice(@ret,$i+1,1); } } else { $i++; } } return \@ret; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CSV file
by CountZero (Bishop) on Oct 31, 2005 at 13:39 UTC | |
by pajout (Curate) on Oct 31, 2005 at 13:57 UTC | |
|
Re^2: CSV file
by azaria (Beadle) on Oct 31, 2005 at 13:55 UTC | |
by pajout (Curate) on Oct 31, 2005 at 14:00 UTC |