Skip to content

Instantly share code, notes, and snippets.

@nyannko
Created March 18, 2017 14:31
Show Gist options
  • Save nyannko/f7083687832b72a5b4106195bb4f2221 to your computer and use it in GitHub Desktop.
Save nyannko/f7083687832b72a5b4106195bb4f2221 to your computer and use it in GitHub Desktop.
#/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