Re: Store multiple dictionaries in a file




Thank you for you answer.

> > I would like to store multiple dictionaries in a file, if possible one per
> > line.
>
> Why "one per line" ?

I agree with you that it sounds like nasty code :-) but there is a good
reason for doing it this way - I think. My code collects data (attributes)
of its current environment, e.g. date, time, location, etc.
These values are put into a dictionary and passed to another program which
processes the data. The dictionary (or vector of attributes) is the only
interface between both progs. The one which creates the dictionary can
forget about it after it has passed it on. This is where the storing comes
into action. In order to be able to re-run an experiment I want to store
the dictionaries in a file. Also the program might not run continuasly,
therefore if I write all of them to a file, on after the other, I would be
able to re-run the experiment much easier.

Hope this makes sense.

Thank you,
Phil

>
> A pretty simple solution could be to store all the dicts in another
> container (list or dict, depending on how you need to retrieve'em, but
> from what you explain I'd say a list) and then pickle this container.
.



Relevant Pages

  • Re: Writing huge Sets() to disk
    ... pushes it's internal dictionaries ... > Almost anything you do copies references. ... > store the values on disc in a reasonably efficient manner. ... bsddb creaps on me that I can store as a key or value only a string. ...
    (comp.lang.python)
  • Re: Design question.
    ... I need to store a number of dictionaries in certain place. ... by the module dicts? ... then your design is correct. ...
    (comp.lang.python)
  • Re: handling tabular data in python--newbie question
    ... Just jump in python few days. ... I am planning to use the column names as variables to access data, currently I am thinking of using a dictionary to store this file but did not figure out a elegant way to start. ... Let's store the rows in a dictionary of dictionaries, using the first column to index each row. ... rdict = dict(zip(names, cols)) ...
    (comp.lang.python)
  • Re: Multikey Dict?
    ... > I could store all of them in a list. ... > that is already in the individual dicts within people. ... > choose one of several unambiguous keys as a key. ... reference use the same object in both dictionaries. ...
    (comp.lang.python)
  • Re: Writing huge Sets() to disk
    ... > have enough disk space to store 1E15 keys. ... I was really hoping I'll get an answer how to alter the indexes for dictionaries ...
    (comp.lang.python)