[Tutor] Writing a dictionary to txt file

nzbz xx nzbzxx at gmail.com
Sat Aug 29 23:28:51 EDT 2020


The original txt file is written in this format:

Plant 1
date & time
description
description
description
(Blank line)
Plant 2
...
....
...

I have converted this file into dict = {'Plant 1':
['datetime','description','description','description'], 'Plant2' :
['datetime',....]}. So how can i write this dict back to the txt file in
the same format?


On Sun, Aug 30, 2020 at 7:31 AM Cameron Simpson <cs at cskk.id.au> wrote:

> On 29Aug2020 22:33, Alan Gauld <alan.gauld at yahoo.co.uk> wrote:
> >On 29/08/2020 18:17, nzbz xx wrote:
> >> I have a txt file of records that I have converted into a dictionary.
> How
> >> can I write this dictionary back to the txt file after
> appending/replacing
> >> the values of the dictionary keys?
> >
> >There are sio many ways to do this that its hard to give advice without
> >more details.
> >
> >Do you have a data specification for the output?
>
> Yes, because the OP got the data from that same text file to start with.
>
> So the OP just needs to reverse the parsing process used to read the
> data.
>
> Without seeing the code it is hard to be more specific.
>
> Cheers,
> Cameron Simpson <cs at cskk.id.au>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list