Created
December 9, 2019 22:24
-
-
Save ruthtillman/5d4807d1522e40a2f12d014158ee4563 to your computer and use it in GitHub Desktop.
starter python script
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
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