Skip to content

Instantly share code, notes, and snippets.

@rob-b
Created September 29, 2014 09:19
Show Gist options
  • Save rob-b/8076767224b1e634fca3 to your computer and use it in GitHub Desktop.
Save rob-b/8076767224b1e634fca3 to your computer and use it in GitHub Desktop.
Requires `PyGithub` and `unicodecsv`
import cStringIO
import unicodecsv
from github import Github
repo = 'USER/REPO'
token = 'GITHUBTOKENHERE'
def main():
g = Github(token)
github_repo = g.get_repo(repo)
header = [u'#', u'Title', u'State', u'Labels']
fo = cStringIO.StringIO()
csvout = unicodecsv.writer(fo)
csvout.writerow(header)
rows = []
for issue in github_repo.get_issues():
labels = ','.join([l.name for l in issue.labels])
rows.append((issue.number, issue.title, issue.state, labels))
for row in sorted(rows, key=lambda s: s[-1]):
csvout.writerow(row)
print fo.getvalue()
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment