Last active
April 27, 2019 22:28
-
-
Save JohnnyFang/0cc08fc6c67fce6eefb8c0b1b06b2e98 to your computer and use it in GitHub Desktop.
loading json files (python 3)
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
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