Last active
May 17, 2017 12:12
-
-
Save alexbowe/10624449 to your computer and use it in GitHub Desktop.
Find the Nth Tweet from your Twitter archive .csv file
This file contains hidden or 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
# To run, from shell type: python tweet_finder.py | |
# Must be run in the same directory as the downloaded csv file. | |
import csv | |
# Modify this number if you want a different nth Tweet | |
# Should be 1-based (i.e. first tweet is the 1th, not 0th) | |
num = 40000 | |
# Change the path if you want to run it from a different directory | |
path = "tweets.csv" | |
with open(path, "r") as f: | |
# [1:] to remove the header | |
tweets = list(csv.reader(f))[1:] | |
if len(tweets) < num: | |
print "There are less than %d tweets." % (num) | |
else: | |
# Archive Format: Reverse chronological order. Last field is Tweet content. | |
print tweets[-num][-1] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment