Thats an interesting data structure Dennis. I will actually be running this type of query many times preferable in an ad-hoc environment. That makes it tough for sqlite3 since there will be several hundred thousand tuples. <div>
<br></div><div><br><br><div class="gmail_quote">On Fri, Jul 20, 2012 at 12:18 AM, Dennis Lee Bieber <span dir="ltr"><<a href="mailto:wlfraed@ix.netcom.com" target="_blank">wlfraed@ix.netcom.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">{NOTE: preferences for comp.lang.python are to follow the RFC on<br>
"netiquette" -- that is, post comments /under/ quoted material, trimming<br>
what is not relevant... I've restructured this reply to match}<br>
<br>
On Thu, 19 Jul 2012 21:28:12 -0400, Rita <<a href="mailto:rmorgan466@gmail.com">rmorgan466@gmail.com</a>><br>
declaimed the following in gmane.comp.python.general:<br>
<div><div class="h5"><br>
><br>
><br>
> On Thu, Jul 19, 2012 at 8:52 PM, Dave Angel <<a href="mailto:d@davea.name">d@davea.name</a>> wrote:<br>
><br>
> > On 07/19/2012 07:51 PM, Rita wrote:<br>
> > > Hello,<br>
> > ><br>
> > > I have data in many files (/data/year/month/day/) which are named like<br>
> > > YearMonthDayHourMinute.gz.<br>
> > ><br>
> > > I would like to build a data structure which can easily handle querying<br>
> > the<br>
> > > data. So for example, if I want to query data from 3 weeks ago till<br>
> > today,<br>
> > > i can do it rather quickly.<br>
> > ><br>
> > > each YearMonthDayHourMinute.gz file look like this and they are about 4to<br>
> > > 6kb<br>
> > > red 34<br>
> > > green 44<br>
> > > blue 88<br>
> > > orange 4<br>
> > > black 3<br>
> > > while 153<br>
> > ><br>
> > > I would like to query them so I can generate a plot rather quickly but<br>
> > not<br>
> > > sure what is the best way to do this.<br>
> > ><br>
> > ><br>
> > ><br>
> ><br>
> > What part of your code is giving you difficulty?  You didn't post any<br>
> > code.  You don't specify the OS, nor version of your Python, nor what<br>
> > other programs you expect to use along with Python.<br>
> ><br>
> Using linux 2.6.31; Python 2.7.3.<br>
> I am not necessary looking for code just a pythonic way of doing it.<br>
> Eventually, I would like to graph the data using matplotlib<br>
><br>
><br>
</div></div>        Which doesn't really answer the question. After all, since the<br>
source data is already in date/time-stamped files, a simple, sorted,<br>
"glob" of files within a desired span would answer the requirement.<br>
<br>
        But -- it would mean that you reparse the files for each processing<br>
run.<br>
<br>
        An alternative would be to run a pre-processor that parses the files<br>
into, say, an SQLite3 database (and which can determine, from the<br>
highest datetime entry in the database, which /new/ files need to be<br>
parsed on subsequent runs). Then do the query/plotting from a second<br>
program which retrieves data from the database.<br>
<br>
        But if this is a process that only needs to be run once, or at rare<br>
intervals, maybe you only need to parse the files into an in-memory data<br>
structure... Say a list of tuples of the form:<br>
<br>
        [       (datetime, {color: value, color2: value2, ...}), (datetime2,<br>
...) ]<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
        Wulfraed                 Dennis Lee Bieber         AF6VN<br>
        <a href="mailto:wlfraed@ix.netcom.com">wlfraed@ix.netcom.com</a>    <a href="HTTP://wlfraed.home.netcom.com/" target="_blank">HTTP://wlfraed.home.netcom.com/</a><br>
<br>
--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br><br clear="all"><div><br></div>-- <br>--- <span>Get your facts first, then you can distort them as you please.</span>--<br>
</div>