Last active
October 30, 2017 06:42
-
-
Save ninodafonte/1ca631fd8f916cb1f61ee702b5bb4633 to your computer and use it in GitHub Desktop.
Read Json file and insert into Mongodb #mongo #python
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
with open('agile_users_geo.json') as data_file: | |
data = json.load(data_file) | |
for item in data['data']: | |
key = {"id": item['features']['id']} | |
data = {"geo_type": item['features']['geo_type'], | |
"location": item['features']['location'], | |
"name": item['features']['name'], | |
"primary_geo": item['features']['primary_geo'], | |
"screen_name": item['features']['screen_name'], | |
"tweets": item['features']['tweets']} | |
collection.update(key, data, upsert=True) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment