Skip to content

Instantly share code, notes, and snippets.

View kelvinn's full-sized avatar

Kelvin Nicholson kelvinn

View GitHub Profile
@kelvinn
kelvinn / twitter_convert.py
Created November 21, 2013 06:41
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()