claudiu-c
4/27/2017 - 9:43 AM

Python api get last commit date into a csv file

Python api get last commit date into a csv file

from github import Github
import csv
import calendar
import dateutil.parser

data = []
ofile  = open('data/m1.csv', "w")
writer = csv.writer(ofile, delimiter=',', quotechar='"', quoting=csv.QUOTE_ALL)
for item in module_list:
    repo = g.get_repo(item[0])
    data.append(
        [
            item[0],
            calendar.timegm(repo.created_at.timetuple()),
            int(dateutil.parser.parse(repo.get_commits()[0].last_modified).timestamp())
        ]
    )

for row in data:
    writer.writerow(row)
ofile.close()