Add python script to read tweets from Twitter archive

This commit is contained in:
Eryn Wells 2015-01-19 13:20:32 -08:00
parent 5756f4912a
commit 7318806856

20
read_twitter_corpus.py Executable file
View file

@ -0,0 +1,20 @@
#!/usr/bin/env python
import csv
import sys
def main():
if len(sys.argv) < 2:
sys.stderr.write("Usage: {} [twitter csv]".format(sys.argv[0]))
return -1
with open(sys.argv[1], 'rb') as csv_file:
csv_reader = csv.reader(csv_file)
for row in csv_reader:
tweet = row[5]
sys.stdout.write(tweet)
if tweet[-1] != '\n':
sys.stdout.write('\n')
if __name__ == '__main__':
sys.exit(main())