hujunsimon has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: How to transform the data with Perl
by Bloodnok (Vicar) on Oct 05, 2009 at 12:42 UTC
    Hmmm, I'm having a problem reading your post - feel free to take note of the emboldened advice (Put <p> </p> tags around your paragraphs. Put <code></code> tags around your code and data!) at the bottom of the composition page.

    I use Text::xSV to read (and write) text delimited (in this case '_' ?) files a line at a time </plug>

    A user level that continues to overstate my experience :-))
Re: How to transform the data with Perl
by toolic (Bishop) on Oct 05, 2009 at 12:43 UTC
    Preview. Preview. Preview.

    You need to edit your post to break up your data. It appears as one long line, which makes it difficult to understand your question. If your actual data really is a single long line of characters with no whitespace or newlines, then truncate it -- I doubt we need to see that much data.

Re: How to transform the data with Perl
by jethro (Monsignor) on Oct 05, 2009 at 13:06 UTC
    What is link_no? Where are the commas in your Comma Separated Values? Time_interval seems to be a 15-minute part of a day, right? If you want to keep the data structure as simple as possible you can still store all data into one array, just add 96 to the index if you want to access the weekend data.

    For a clean maintainable solution you have to use a multi-dimensional array, something like this:

    #Store an entry: $speed[1][1]['weekday']= 32.61712; #or when you load values from a CSV file (I assume all values on one l +ine: my $line=<csvfile>; my @speeds= split $line; my $link_no=1; my $i=1; my $day='weekday'; foreach (@speeds) { $speed[$link_no][$i++][$day]= $_; }
    If you want to have each day in the database instead of only data for 'weekday' and 'weekend', you can still use above and then either copy the 'weekday' data to the 'monday', 'tuesday' slots or copy only the link (i.e. $speed[$link_no][$i++]['monday']= $speed[$link_no][$i++]['weekday'];, which would share the data, i.e. if you change data in the 'weekday' set, you also change it in the 'monday' set)

      sorry....... i have changed the format of my post.

      Jethro: the common is at every 192 of speed value, i trucated the dataset and only put one link speed record here, there are 66 links in the dataset. sorry for the confusion. thanks for your suggestion, i will give it a try now.

        It seems you do not understand the problem with your post format. Perhaps you may have noticed that to see the far right of your post, people need to scroll many, many screenfuls? This is considered very impolite and the solution is to surround that one very, very long line with <code> tags, like this:
        <code> 32.61712_29.23591_24.84628_22.84434_30.59529_28.76819_35.03523_30.9736 +7_30.5064_38.87624_49.87962_51.24486_47.32718_48.00002_51.71957_44.31 +798_39.75034_48.64877_30.88166_36.76909_54.46225_38.02563_30.29589_37 +.91334_21.44945_28.95672_22.03353_21.29655_23.84956_19.28472 </code>

        Using code tags causes the text to wrap around. We still know that this is one long line because each wrapped line begins with a red + sign. The red plus doesn't show up in your input window though because it is still one long line there. Please, please, do what I did above to your original post so you won't annoy people further.

        Best, beth