in reply to CSV file reading and comparison
$goldcsv = @ARGV[0]; #$newcsv = @ARGV[1]; my %goldhash; my @keyarray; open GOLD, "$goldcsv"; my $i = 0; while (<GOLD>) { chomp; $i=$i+1; if ($i eq 1) { @temparray = split (",",$_); my $j=0; foreach $elem (@temparray) { $j= $j+1; next if ($j eq 1); push (@keyarray, $elem); } next; } @temparray = split(",",$_); $testcasename = @temparray[0]; foreach my $value (1..$#temparray) { $goldhash{$testcasename}{$keyarray[$value-1]} = $temparray[$va +lue]; } } for $testcase (keys %goldhash) { print "$testcase: "; for $value (keys %{ $goldhash{$testcase} }) { print "$value = $goldhash{$testcase}{$value} "; } print "\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: CSV file reading and comparison
by toolic (Bishop) on Feb 27, 2008 at 14:06 UTC | |
by tsk1979 (Scribe) on Mar 03, 2008 at 08:38 UTC |