Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This gist shows how to take the timeline backup from Twitter and transform it into a dictionary using the headers as keys. For example, if the CSV file looked had two columns, col1 and col2, it would result in list that looked like: [{'col1': 'hello', 'col2': 'world'}, {'col1': 'bye', 'col2': 'world'}] It also converts the format used by Twitter…
import csv
from dateutil import parser
qs_list = []
with open('C:\\Users\\username\\Desktop\\tweets.csv', 'rb') as csvfile:
qsreader = csv.reader(csvfile, delimiter=',', quotechar='"')
header = qsreader.next()
for row in qsreader:
d = parser.parse(row[6])
row[6] = d.isoformat()
qs_list.append(dict(zip(header,row)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.