Thanks for all advices and sorry for being an annoyance for the format of my post, :(. i have corrected them now. i'm a newbie in this forum, but try to learn the etiqutte quickly.
thank you for the help, i have made my program working now. it's really cool.
here is part of my code:#!/usr/bin/perl use warnings; $file =... open (TEMP, $file) or die("Error: cannot open $file\n"); $outfile =... open (OUTPUT,">$outfile"); select(OUTPUT); # explicitly select the new file for output #declare variables $counter_A=0; $counter_B=0; #counter for time of the day $counter_C=2; #counter for day of the week,date starts on + tuesday @interval = (1..35040); #15 mins interval over a year 365 days $nline = "\n"; $scomma = ", "; $i = 0; while ($line = <TEMP>) { @column = split (/,/,$line); @speed = split (/_/,$column[5]); foreach $timeint (@interval) { if ($counter_A==4) { $counter_A = 0; $counter_B++; if ($counter_B==24) {$counter_B = 0; $counter_C++; $i = 0; if (($counter_C>=6) && ($counter_C<8)) { $i = 96; } if ($counter_C==8) { $counter_C = 1; } } } print OUTPUT trim($column[0]).$scomma.trim($column[1]).$scomma.$speed[ +$i].$nline $counter_A++; $i++; } }
the program will read the csv file and place the speed data according to time of the day and day of the week.
i know the code can be more simplified, but it does exactly the job i wanted, also considering i only learned perl for 36 hours, so i'm pretty happy, :-) !
thanks for all PerlMonks, any comments will be welcomed !In reply to Re^4: How to transform the data with Perl
by hujunsimon
in thread How to transform the data with Perl---Solved !!!
by hujunsimon
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |