If I have a json file with multiple json objects such as following
{"created_at":"Sun Apr 16 02:00:14 +0000 2017","id":853427785339084800,"id_str":"853427785339084800"}
{"created_at":"Sun Apr 16 02:03:24 +0000 2017","id":853428582613475332,"id_str":"853428582613475332"}
I want to loop all the json objects add add new element together with value through user input in command line one by one. Is it possible because my format not in json array?
import json
import pandas as pd
from pprint import pprint
tweets_data_path = 'data.json'
tweets_data = []
tweets_file = open(tweets_data_path, "r")
for line in tweets_file:
try:
tweet = json.loads(line)
tweets_data.append(tweet)
except:
continue
pprint(tweets_data)