Am I doing this the python way? (list of lists + file io)

Discussion in 'Python' started by R. David Murray, Jun 8, 2009.

  1. Horace Blegg <> wrote:
    > So, Example: I'll read in a CSV file (just one, for now.) and store it into
    > a list. Sometime later, I'll get another CSV file, almost identical/related
    > to the first. However, a few values might have changed, and there might be a
    > few new lines (entries) or maybe a few less. I would want to compare the CSV
    > file I have in my list (in memory) to new CSV file (which I would probably
    > read into a temporary list). I would then want to track and log the
    > differences between the two files. After I've figured out what's changed, I
    > would either update the original CSV file with the new CSV's information, or
    > completely discard the original and replace it with the new one (whichever
    > involves less work). Basically, lots of iterating through each entry of each
    > CSV file and comparing to other information (either hard coded or variable).
    >
    > So, to reiterate, are lists what I want to use? Should I be using something
    > else? (even if that 'something else' only really comes into play when
    > storing and operating on LOTS of data, I would still love to hear about it!)


    Given your description, I don't see any reason to prefer any alternate
    data structure. 1000 small CSV files should fit in a modern computer's
    memory with no problem...and if it does become an issue, worry about it
    then.

    One thought, though: you might want to create a list subclass to hold
    your data, so that you can put useful-to-you methods on the subclass...

    --
    R. David Murray http://www.bitdance.com
    IT Consulting System Administration Python Programming
     
    R. David Murray, Jun 8, 2009
    #1
    1. Advertising

  2. R. David Murray

    Guest

    R. David Murray:
    > Given your description, I don't see any reason to prefer any alternate
    > data structure.  1000 small CSV files should fit in a modern computer's
    > memory with no problem...and if it does become an issue, worry about it
    > then.


    The OP can also try the "diff" command that can be found implemented
    both on Linux and Windows.

    Bye,
    bearophile
     
    , Jun 8, 2009
    #2
    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. =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==

    List of lists of lists of lists...

    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==, May 8, 2006, in forum: Python
    Replies:
    5
    Views:
    410
    =?UTF-8?B?w4FuZ2VsIEd1dGnDqXJyZXogUm9kcsOtZ3Vleg==
    May 15, 2006
  2. yomgui

    list of lists of lists ....

    yomgui, Jul 28, 2006, in forum: Python
    Replies:
    6
    Views:
    315
    yomgui
    Jul 31, 2006
  3. bahoo
    Replies:
    3
    Views:
    308
    Bruno Desthuilliers
    Apr 3, 2007
  4. antar2
    Replies:
    2
    Views:
    395
    Bighead
    Jul 17, 2008
  5. Jason
    Replies:
    7
    Views:
    4,471
Loading...

Share This Page