Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re: reading a delimited file and selecting values from it

by nefigah (Monk)
on Mar 12, 2008 at 02:28 UTC ( #673660=note: print w/replies, xml ) Need Help??

in reply to reading a delimited file and selecting values from it

It's possible there's some tools out there that would make this easier, but to tackle it yourself, here are some ideas to get you started. If you need specific help on a certain part of this, just ask.

Create a hash or something to hold the data you want to keep. One idea might be to have the keys be like '1', '1.5', '2', '2.5' etc. (i.e. a key for the hour and a key for the half hour for each of the 24 hours).

Open the file and go through it line by line, using a regex to separate each line into separate chunks for Quote, Hour, Minute, and Second. This should be relatively painless because the lines seem to be delimited pretty clearly.

Look at the Hours and Minutes returned from the current match to find out where that line should be placed in your hash. (i.e. if $hour = 12 and $minute = 37, it would go in $hash{'12.5'}) and place the quote there. Assuming the file is in chronological order, this should do it for ya. If it's not, you may have to keep track of the seconds and do a comparison to determine if the new value is "higher".

Hopefully that gets you going in the right direction.

I'm a peripheral visionary... I can see into the future, but just way off to the side.

  • Comment on Re: reading a delimited file and selecting values from it

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://673660]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2017-10-23 23:51 GMT
Find Nodes?
    Voting Booth?
    My fridge is mostly full of:

    Results (285 votes). Check out past polls.