-
-
Save brendano/1380f006c233c5901514 to your computer and use it in GitHub Desktop.
tw2created_at_iso.py
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
#!/usr/bin/env python | |
import ujson as json | |
import time,sys | |
from datetime import datetime | |
def parse_date(twitter_lame_datetime_string): | |
# e.g. the 'created_at' field | |
ts = time.strptime(twitter_lame_datetime_string, "%a %b %d %H:%M:%S +0000 %Y") | |
return datetime(*ts[:7]) | |
for line in sys.stdin: | |
tw = line.split('\t')[-1] | |
tw = json.loads(tw) | |
d = parse_date(tw['created_at']) | |
created_at_iso = d.strftime("%Y-%m-%dT%H:%M:%S") | |
print "%s\t%s" % (created_at_iso, line.rstrip('\n')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment