capriguy84 has asked for the wisdom of the Perl Monks concerning the following question:
The task is to parse lines and computes values high/low first/last value for column 4 for each second.NAME 6/1/2011 9:30:00 16.76 469898 Q 0 NAME 6/1/2011 9:30:00 16.75 300 Q 0 NAME 6/1/2011 9:30:00 16.75 150 Q 0 NAME 6/1/2011 9:30:01 16.76 756 Q 0 NAME 6/1/2011 9:30:01 16.76 300 Q 0 NAME 6/1/2011 9:30:02 16.76 100 Q 0
while (<FILE>) { $csv->parse($_); my @columns = $csv->fields(); $start_time = str2time($columns[1].' '.$columns[2]); next unless ($curr_time != $start_time) { $exchange = $column[5]; push (@arr1, $column[3]); push (@arr2, $column[4]); push (@arr3, $column[5]); $curr_time = str2time($columns[1].' '.$columns[2]); print "Avg= high= low= in one second=";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parse CSV lines and process for each second
by blue_cowdawg (Monsignor) on Sep 07, 2011 at 18:51 UTC | |
by capriguy84 (Novice) on Sep 07, 2011 at 19:50 UTC | |
by blue_cowdawg (Monsignor) on Sep 07, 2011 at 20:21 UTC | |
by capriguy84 (Novice) on Sep 07, 2011 at 21:16 UTC | |
by davies (Monsignor) on Sep 07, 2011 at 22:04 UTC |