Appending data to a json file

Robin Koch robin.koch at t-online.de
Tue Apr 4 12:20:50 EDT 2017


Am 04.04.2017 um 04:59 schrieb Dave:
> I created a python program that gets data from a user, stores the data
> as a dictionary in a list of dictionaries.  When the program quits, it
> saves the data file.  My desire is to append the new data to the
> existing data file as is done with purely text files.  However, I can't
> find a way to do that.  The advice I have seen on the web is to load the
> data when the program starts, append the new user input to the list,
> then re-write the data file.  Is that the best way, or is there a better
> way?

As explained by others JSON does not allow text based data appending.

But maybe you take a look at YAML (if it's appropriate for your project).

-- 
Robin Koch


More information about the Python-list mailing list