-
Notifications
You must be signed in to change notification settings - Fork 0
/
filter.py
33 lines (29 loc) · 935 Bytes
/
filter.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
import json
import time
import csv
import sys
types = ['cloud', 'iot', 'hpc']
tags = {
'cloud' : {'cloud', 'container'},
'iot' : {'iot', 'internet of things', 'container'},
'hpc' : {'hpc', 'high performance computing', 'container'}
}
output = open('dataset.csv', 'w')
writer = csv.writer(output)
keywords = ['full_name', 'stargazers_count', 'description', 'html_url']
writer.writerow([*keywords, 'type'])
for type in types:
with open(f'github-results/{type}.json', 'r') as fj:
data = json.load(fj)
items = data['items']
for item in items:
desc = item['description']
if not desc:
continue
desc = desc.replace("-", " ").lower()
for tag in tags[type]:
if tag in desc:
repo = [item[k] for k in keywords]
writer.writerow([*repo, type])
break
output.close()