-
Notifications
You must be signed in to change notification settings - Fork 1
/
scraps.py
43 lines (31 loc) · 1 KB
/
scraps.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
39
40
41
42
43
import json
def a():
with open('four_square_a.txt','r') as f:
r = json.load(f)
here = r['items'][0]['venue']['categories']
all_items = r['items']
set_of_categories = set()
for i in all_items:
the_cat = i['venue']['categories'][0]['shortName']
set_of_categories.add(the_cat)
print(set_of_categories)
print(set_of_categories)
def b():
with open('categories_data.txt') as f:
categories = json.load(f)
#return categories
set_of_food_cats = set()
for cat in categories:
#print(cat[0])
#print(cat['name'])
if cat['name'] == 'Food':
#return(cat)
for subcat in cat['categories']:
#print(subcat)
#return(subcat)
#print('adding:{}'.format(subcat['id']))
set_of_food_cats.add(subcat['id'])
#print(set_of_food_cats)
return(set_of_food_cats)
if __name__ == '__main__':
t = b()