Created
March 18, 2017 14:31
-
-
Save nyannko/f7083687832b72a5b4106195bb4f2221 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
# -*- coding: utf-8 -*- | |
import json | |
import csv | |
import os | |
from os import walk | |
import re | |
f =[] | |
for (dirpath, dirnames, filenames) in walk("/Users/umr/Documents/information retrieval/project/testtweetform"): | |
f.extend(filenames) | |
break | |
for i, n in enumerate(f): | |
if(re.match('[0-9]', n) is None): | |
f.pop(i) | |
f.pop() | |
dic = {} | |
with open('out.json', 'w') as fp: | |
for index, uid in enumerate(f): | |
with open(f[index], 'r') as fa: | |
out = {} | |
for i, line in enumerate(fa): | |
tweet = json.loads(line) | |
output = tweet['previous_cursor'] | |
out[i] = output | |
dic[uid] = out | |
fp.write(json.dumps(dic)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment