Created
March 8, 2019 11:12
-
-
Save sreevardhanreddi/4712639b198e488cea6221e28189cce7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list_of_dicts = [ | |
{ "prop": 1, "attr": 2 }, | |
{ "prop": 3, "attr": 4 } | |
# ... | |
] | |
with open(filepath, 'w') as f: | |
f.write('[') | |
for obj in list_of_dicts[:-1]: | |
json.dump(obj, f) | |
f.write(',') | |
json.dump(list_of_dicts[-1], f) | |
f.write(']') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment