W W wrote:
> I was toying around with dictionaries/files/etc, and it's possible to
> loop over the dictionary, writing each key/value pair to the file on
> one line with a comma between them
> And if you knew certain values might be ints, you could use
>
> try: mydict[int(row[0])] = row[1]
This
On Mon, Apr 7, 2008 at 2:50 PM, Kent Johnson <[EMAIL PROTECTED]> wrote:
> Jerrold Prothero wrote:
> >
> > I've been trying to understand how writing a dictionary to a file & reading
> > it back should work.
> >
> > It's been suggested that if I had a clue, I'd use pickle, but since I
> > star
Jerrold Prothero wrote:
>
> I've been trying to understand how writing a dictionary to a file & reading
> it back should work.
>
> It's been suggested that if I had a clue, I'd use pickle, but since I
> started
> looking at the csv (comma separated values) module, which also supports
> writing
On Mon, Apr 7, 2008 at 1:09 PM, Jerrold Prothero <[EMAIL PROTECTED]> wrote:
> Relevant Python 2.5 documentation sections are 9.1.1 and 9.1.4. My
> question boils down to this: what does writerows want as an argument
> for a dictionary?
A list of dictionaries. One dictionary for each row you would
"Jerrold Prothero" <[EMAIL PROTECTED]> wrote
> It's been suggested that if I had a clue, I'd use pickle
Shelve is based on Pickle and makes a file look
somewhat like a dictionary. It might do all you need
and is a standard module.
> looking at the csv (comma separated values) module, which also
Jerrold Prothero wrote:
>
> I've been trying to understand how writing a dictionary to a file &
> reading
> it back should work.
> [snip]
>
> Here are three guesses at how to call writerows, with error traces.
> [snip]
> 2)
>
> w.writerows(d)
>
> Traceback (most recent call last):
> Fi
I've been trying to understand how writing a dictionary to a file & reading
it back should work.
It's been suggested that if I had a clue, I'd use pickle, but since I
started
looking at the csv (comma separated values) module, which also supports
writing dictionaries out to a file, I at least want