Created
November 21, 2013 06:41
-
-
Save kelvinn/7576994 to your computer and use it in GitHub Desktop.
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…
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
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