-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmisc.py
38 lines (26 loc) · 812 Bytes
/
misc.py
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
32
33
34
35
36
37
38
"""
misc.py
Additional helper functions needed.
"""
import json
def get_max_ups(pathto_cleaned):
# need to open subreddits_important file
namesfile = open('scraper/scraper/subreddits_important', 'r')
results = {}
for sr_name in namesfile:
# need to open the subreddit datafile - assuming in separate dir
sr_file = open(pathto_cleaned + sr_name[1:-2], 'r')
max_ups = -1
sr_id = -1
for row in sr_file:
obj = json.loads(row)
if obj['ups'] > max_ups:
# replace
max_ups = obj['ups']
# debug: print sr_name[1:-2] + ': ' + str(max_ups)
results[sr_name[1:-2]] = max_ups
sr_file.close()
namesfile.close()
print results
return results
get_max_ups('../Cleaned/')