Skip to content

Instantly share code, notes, and snippets.

@neelindresh
Created February 20, 2019 19:05
Show Gist options
  • Save neelindresh/15fce8ed53be2242f9b6eabeddff9340 to your computer and use it in GitHub Desktop.
Save neelindresh/15fce8ed53be2242f9b6eabeddff9340 to your computer and use it in GitHub Desktop.
import json
def string_to_json(line):
import ast
jsonval=ast.literal_eval(line)
return jsonval
location=[]
for line in open('tweetCur.json', 'r',encoding="utf-8"):
line=string_to_json(line)
print(line['user']['name'])
#print(line.keys())
if line['user']['location']:
print(line['user']['location'])
location.append(line['user']['location'])
for l in location:
with open('location.txt','a') as w:
try:
w.write(l+'\n')
except:
continue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment