Last active
February 5, 2022 22:45
-
-
Save jonathanmc/131bd6685e5d0447072de045a4b5f427 to your computer and use it in GitHub Desktop.
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
# this loads a JSON dump as for example from TWINT, and pulls out three fields, and then saves as TEXT. | |
import json | |
loadedjson = [] | |
for line in open('TWEETS.json', 'r'): | |
loadedjson.append(json.loads(line)) | |
dates = [] | |
tweets = [] | |
links = [] | |
# pull date, tweet, and URL fields only | |
for x in loadedjson: | |
dates.insert(0,x['date']) | |
tweets.insert(0,x['tweet']) | |
links.insert(0,x['link']) | |
# zip it | |
zipped = zip(dates, links, tweets) | |
zipped_list = list(zipped) | |
# if want to see your work | |
# print(zipped_list) | |
# now slap it in a string with new line between each | |
zipped_list_string = '\n'.join(map(str,zipped_list)) | |
# save to TXT | |
f = open('TWEETSOUT.txt', 'w') | |
f.write(zipped_list_string) | |
f.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment