farhan has asked for the wisdom of the Perl Monks concerning the following question:
open(RAW,"raw_data") or die ("could not open the file $!"); while(<RAW>) { chomp; next if /^(\s)*$/; my @this_record = split(/,/,$_); push(@records,\@this_record); } my @sorted = sort{$a->[0] <=> $b->[0]} @records; foreach $record (@sorted) { if($record->[3] >= $record->[4]) { $final = $record->[3]; } else { $final = $record->[4]; } print "$record->[0] $record->[1],$record->[3],$record->[4],$final\n"; } close(RAW);
2006-07-17 Retitled by Corion, as per Monastery guidelines
Original title: 'Sorting'
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Sorting a CSV file
by McDarren (Abbot) on Jul 17, 2006 at 02:59 UTC | |
by farhan (Novice) on Jul 17, 2006 at 03:44 UTC | |
by McDarren (Abbot) on Jul 17, 2006 at 05:03 UTC | |
by farhan (Novice) on Jul 17, 2006 at 03:40 UTC | |
by McDarren (Abbot) on Jul 17, 2006 at 04:37 UTC | |
Re: Sorting a CSV file
by rsiedl (Friar) on Jul 17, 2006 at 03:39 UTC | |
Re: Sorting a CSV file
by CountZero (Bishop) on Jul 17, 2006 at 14:17 UTC |