-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithubuserscsv.py
More file actions
31 lines (24 loc) · 903 Bytes
/
Copy pathgithubuserscsv.py
File metadata and controls
31 lines (24 loc) · 903 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cPickle as pickle
import glob
import codecs
import unicodecsv as csv
def xstr(s):
if s is None:
return ''
return s
files = glob.glob('data/searchpages/*.html')
needed = []
for file in files:
needed.append(file.split('/')[2][:-5])
users = pickle.load(open('allusersinfo.p', 'rb'))
with open('data/searchusers.csv', 'wb') as f1:
f2 = csv.writer(f1, encoding='utf-8')
f2.writerow(['Id','Name', 'Company','Email','Bio','Blog','Location'])
#f1.write('Name,Compan,Email,Bio,Blog,Location\n')
for user in needed:
if user in users:
x = users[user]
f2.writerow([user,xstr(x['name']),xstr(x['company']),xstr(x['email']),xstr(x['bio']).replace('\n',' '),xstr(x['blog']),xstr(x['location'])])
#f1.write(user+','+xstr(x['name'])+','+xstr(x['company'])+','+xstr(x['email'])+','+xstr(x['bio']).replace('\n',' ')+','+xstr(x['blog'])+','+xstr(x['location'])+'\n')
else:
print user