Skip to content

Instantly share code, notes, and snippets.

@ggorlen
Last active December 6, 2023 05:57
Show Gist options
  • Select an option

  • Save ggorlen/47c3077093835ff59035dab1f09d14d4 to your computer and use it in GitHub Desktop.

Select an option

Save ggorlen/47c3077093835ff59035dab1f09d14d4 to your computer and use it in GitHub Desktop.
JSON stream reader
# read file in the format of separate JSON objects without outer array
# {}
# {}
# {}
# ...
# https://stackoverflow.com/a/50384432/6243352
# https://stackoverflow.com/a/54666028/6243352
#
# other options:
# jq -s < podcasts.json
# pandas.read_json("podcasts.json", lines=True)
with open("podcasts.json") as f:
for line in f:
parsed = json.loads(line)
print(parsed)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment