Skip to content

Instantly share code, notes, and snippets.

@JohnnyFang
Last active April 27, 2019 22:28
Show Gist options
  • Save JohnnyFang/0cc08fc6c67fce6eefb8c0b1b06b2e98 to your computer and use it in GitHub Desktop.
Save JohnnyFang/0cc08fc6c67fce6eefb8c0b1b06b2e98 to your computer and use it in GitHub Desktop.
loading json files (python 3)
path = "datasets/"
files = ["file1.json", "file2.json", "file3.json", "file4.json", "file5.json"]
for file in files:
file_path = path + file
with open(file_path) as f:
json_data = json.load(f)
for el in json_data:
# we check that 'restaurants' exists and it contains data
if 'restaurants' in el and len(el['restaurants']):
# Do something with our restaurant data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment