Re: best way to handle this in Python

Discussion in 'Python' started by Dennis Lee Bieber, Jul 20, 2012.

  1. On Fri, 20 Jul 2012 06:34:47 -0400, Rita <>
    declaimed the following in gmane.comp.python.general:

    > 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.
    >

    Given the sample data, it wouldn't be that difficult...

    table:
    ID #primary key -- I always include an autoincrement ID
    timepoint datetime #the date/time info from the file name
    color char #the name of the color
    value integer #the count (or whatever that represented)

    You could reduce the table size some by adding a bit of runtime
    processing...

    ...
    timepoint foreign key files (timepoint)
    ...

    files
    ID
    name char #path/name of the source file
    timepoint datetime #the date/time from the file name


    Finding out which new files need to be loaded would involve

    select max(timepoint) from files;

    as that identifies the newest file already loaded.

    Depending on nature of queries you could then do things like

    select color, sum(values) from table
    inner join files on table.timepoint = files.ID
    group by table.color
    where files.timepoint >= "first time of interest"
    and files.timepoint <= "last time of interest"
    order by color

    {The "where" clause might need to be a "having" clause}
    --
    Wulfraed Dennis Lee Bieber AF6VN
    HTTP://wlfraed.home.netcom.com/
     
    Dennis Lee Bieber, Jul 20, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ravikanth[MVP]
    Replies:
    6
    Views:
    3,927
    Aemca
    Jul 18, 2003
  2. Thomas Scheiderich

    Best way to handle documents in ASP.NET

    Thomas Scheiderich, May 20, 2004, in forum: ASP .Net
    Replies:
    11
    Views:
    2,500
    Jim Corey
    May 20, 2004
  3. Dave Angel

    Re: best way to handle this in Python

    Dave Angel, Jul 20, 2012, in forum: Python
    Replies:
    0
    Views:
    178
    Dave Angel
    Jul 20, 2012
  4. Dennis Lee Bieber

    Re: best way to handle this in Python

    Dennis Lee Bieber, Jul 20, 2012, in forum: Python
    Replies:
    0
    Views:
    183
    Dennis Lee Bieber
    Jul 20, 2012
  5. Ian Kelly
    Replies:
    1
    Views:
    156
    Steven D'Aprano
    Jul 21, 2012
Loading...

Share This Page