Skip to content

Instantly share code, notes, and snippets.

@robinfang
Last active August 29, 2015 14:19
Show Gist options
  • Select an option

  • Save robinfang/edf5ad7d273a0422470e to your computer and use it in GitHub Desktop.

Select an option

Save robinfang/edf5ad7d273a0422470e to your computer and use it in GitHub Desktop.
#coding=utf-8
import datetime
import codecs
if __name__ == "__main__":
result = []
l4 = []
f = codecs.open("3638347916812769_retweets_id_text_time.txt",encoding="utf-8")
rootId = "3638347916812769_retweets"
l = f.readlines()
l2 = [tuple(x.strip().split("\t")) for x in l]
l3 = [(x[0],x[1],datetime.datetime.strptime(x[2],"%Y-%m-%d %H:%M:%S")) for x in l2] # (id,text,time)
l3.sort(key=lambda x:x[2])
for item in l3:
if not "//@" in item[1]:
result.append((rootId,item[0]))
else:
l4.append(item)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment