Skip to content

Instantly share code, notes, and snippets.

@jj0hns0n
Created December 7, 2011 00:16
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 11 You must be signed in to fork a gist
  • Save jj0hns0n/1440754 to your computer and use it in GitHub Desktop.
Save jj0hns0n/1440754 to your computer and use it in GitHub Desktop.
Export GitHub issues to a csv file
import csv
from github2.client import Github
# api settings for github
git_username = ''
git_api_token = ''
git_repo = ''
# csv name
csv_name = "git_hub_issues.csv"
def run_csv():
"""
Export github issues into a csv format
"""
output_csv = csv.writer(open(csv_name, 'wb'), delimiter=',')
github = Github(username=git_username, api_token=git_api_token)
# csv headers
headers = [
'id',
'title',
'body',
'state',
'creator',
'labels',
'created_at',
'updated_at',
'closed_at',
]
# write header rows
output_csv.writerow(headers)
# get the git issues and write the rows to the csv
git_issues = github.issues.list(git_repo)
for git_issue in git_issues:
print git_issue.title
labels = ' '.join(git_issue.labels)
# alot of these are blank because they are not really
# needed but if you need them just fill them out
issue = [
git_issue.number,
git_issue.title.encode('utf8'),
git_issue.body.encode('utf8'),
git_issue.state,
git_issue.user,
labels,
git_issue.created_at,
git_issue.updated_at,
git_issue.closed_at,
]
output_csv.writerow(issue)
if __name__ == '__main__':
run_csv()
@zukowski
Copy link

zukowski commented Dec 9, 2011

Thanks for posting this gist. Came in handy today when I needed to produce an issues report. I forked and added an option to pull in closed issues. Cheers.

@gavinr
Copy link

gavinr commented Apr 20, 2020

Here's a command line tool: https://github.com/gavinr/github-csv-tools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment