forked from agraebe/stacks-community-projects
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathenrich.py
49 lines (43 loc) · 1.28 KB
/
enrich.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
44
45
46
47
48
import os
import csv
from github import Github
token = os.environ['GITHUB_TOKEN']
g = Github(token)
repos = []
with open("github-repos.csv") as csvfile:
reader = csv.DictReader(csvfile)
for row in reader:
print(row["Repository"])
try:
repo = g.get_repo(row["Repository"])
repos.append(repo)
except:
print("Could not find GitHub repository", row["Repository"])
with open("github-repos-enriched.csv", mode="w") as csv_file:
fieldnames = [
"url",
"name",
"description",
"homepage",
"forks",
"stars",
"subscribers_count",
"watchers_count",
"created_at",
]
writer = csv.DictWriter(csv_file, fieldnames=fieldnames, delimiter=",")
writer.writeheader()
for repo in repos:
writer.writerow(
{
"url": repo.url,
"name": repo.name,
"description": repo.description,
"homepage": repo.homepage,
"forks": repo.forks_count,
"stars": repo.stargazers_count,
"subscribers_count": repo.subscribers_count,
"watchers_count": repo.watchers_count,
"created_at": repo.created_at,
}
)