Skip to content

Instantly share code, notes, and snippets.

@kingofhawks
Created October 10, 2013 03:38
Show Gist options
  • Save kingofhawks/6912669 to your computer and use it in GitHub Desktop.
Save kingofhawks/6912669 to your computer and use it in GitHub Desktop.
export github issues to CSV files
__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