Skip to content

Instantly share code, notes, and snippets.

@casprwang
Created December 7, 2016 19:57
Show Gist options
  • Save casprwang/5cd731a7f0eae5e61d7b235f81442bca to your computer and use it in GitHub Desktop.
Save casprwang/5cd731a7f0eae5e61d7b235f81442bca to your computer and use it in GitHub Desktop.
import json
with open('python222.json', 'r') as f:
geo_data = {
"type": "FeatureCollection",
"features": []
}
for line in f:
tweet = json.loads(line)
if tweet['coordinates']:
geo_json_feature = {
"type": "Feature",
"geometry": tweet['coordinates'],
"properties": {
"text": tweet['text'],
"created_at": tweet['created_at'],
"name": tweet['user']['name'],
"location": tweet['place']['full_name']
}
}
geo_data['features'].append(geo_json_feature)
# Save geo data
with open('geo_data222.json', 'w') as fout:
fout.write(json.dumps(geo_data, indent=2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment