#π Im trying to append dictionaries to a json file but dont know how to seperate them.
27 messages Β· Page 1 of 1 (latest)
@dusk badge
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
you generally wouldn't use "a" mode to append data to a json
you would load the json, update the dict, then write it out again
update the dict im trying to add ?
it depends on how you want your data structured
you can have a list of dicts if you want
that way you can "append" to the json data by appending to the list
yeah im trying to have a big list that has dicts in it
so your JSON would look like [{...}, {...}, ...]
then that should work fine
why are you using a json file to store data that you update partially?
you should use sqlite
i dont know what that is
im a beginner to python
im just trying to store information thats in dictionaries and be able to access them later
it's a database built into python https://docs.python.org/3/library/sqlite3.html
https://docs.python.org/3/library/shelve.html is good it has a sqlite backend
im not trying to over complicate it tho rn
shelve will be the simplest then
the file is only being updated when the function finishes its loop
wouldnt just having a json file be easier to access later and such
sqlite would be ideal
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.