Others have answered your question much as I would, but I would like to add another possibility that no one seems to have offered. Perhaps you already have the "best data structure" -- a file.

I don't know what your requirements are, but assuming your data file is in date order (as it appears to be), the cost of opening and searching through that file may be small enough for you to do it repeatedly. Of course, if "repeatedly" really means "many times per second" that's probably not true :-)

Update: You said in an earlier post that you'll be looking up these values about 8000 times per day, that's about once every 10 seconds which certainly enough time to open and search a file. Especially if you do something smart like keep each days worth of data in separate files rather than all of the data in one big file.

Also, if efficient look up is necessary and your data are coming in at fixed times like that, you could use a hash. Convert the date/time to a GMT value and for each date/time that you want to find the "nearest" barometric pressure, normalize it to one of your fixed times and do a hash lookup


In reply to Re: Data structure advice by duff
in thread Data structure advice by robinbowes

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.