Skip to content

Instantly share code, notes, and snippets.

@ruthtillman
Created December 9, 2019 22:24
Show Gist options
  • Save ruthtillman/5d4807d1522e40a2f12d014158ee4563 to your computer and use it in GitHub Desktop.
Save ruthtillman/5d4807d1522e40a2f12d014158ee4563 to your computer and use it in GitHub Desktop.
starter python script
import json, csv
with open('all_tweets.csv', 'w', newline='') as CSVfile:
fieldnames= ["id","tweet","created_at"]
writer = csv.DictWriter(CSVfile, fieldnames=fieldnames)
writer.writeheader()
with open("../tweet.js", "r") as myJSON:
recorddata = json.loads(myJSON.read())
for item in recorddata:
the_ID = '"' + item["id"] + '"'
content = item["full_text"]
created = item["created_at"]
writer.writerow({"id" : the_ID, "tweet" : content, "created_at" : created})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment