Created
October 10, 2013 03:38
-
-
Save kingofhawks/6912669 to your computer and use it in GitHub Desktop.
export github issues to CSV files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'simon' | |
# coding=gbk | |
def export_csv(repository,target_csv): | |
import requests | |
resp = requests.get(url=repository) | |
#print resp.text | |
data = resp.json() | |
#print data | |
#print len(data) | |
import csv | |
with open(target_csv, 'wb') as csvfile: | |
#spamwriter = csv.writer(csvfile, delimiter=' ', | |
# quotechar='|', quoting=csv.QUOTE_MINIMAL) | |
spamwriter = csv.writer(csvfile, dialect='excel') | |
spamwriter.writerow(['标题', '内容', '优先级']) | |
for issue in data: | |
#print issue | |
#print issue['title'] | |
#print issue['body'] | |
#print issue['body'].encode("GB18030") | |
#print issue['labels'] | |
priority = '' | |
for label in issue['labels']: | |
#print label | |
priority += label['name'] | |
#print priority | |
#spamwriter.writerow(['Spam'] * 5 + ['Baked Beans']) | |
#spamwriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam']) | |
spamwriter.writerow([issue['title'], issue['body'].encode("GB18030"), priority]) | |
if __name__=="__main__": | |
repository = 'https://api.github.com/repos/kingofhawks/bitcoin/issues' | |
export_csv(repository,'issues.csv') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment