Skip to content

Instantly share code, notes, and snippets.

@glenbot
Created January 6, 2011 23:57
Show Gist options
  • Save glenbot/768875 to your computer and use it in GitHub Desktop.
Save glenbot/768875 to your computer and use it in GitHub Desktop.
Export your open issues in github to a pivotal tracker friendly csv for import, requires github2 python api-client
import csv
from github2.client import Github
# api settings for github
git_username = 'your_git_username'
git_api_token = 'your_git_api_token'
git_repo = 'username/repo_name'
# import all issues as this story type
pivotal_story_type = 'Bug'
# csv name
csv_name = "open_git_hub_issues.csv"
def run_csv():
"""
Export your open github issues into a csv format for
pivotal tracker import
"""
pivotal_csv = csv.writer(open(csv_name, 'wb'), delimiter=',')
github = Github(username=git_username, api_token=git_api_token)
# pivotals csv headers
headers = [
'Id',
'Story',
'Labels',
'Story Type',
'Estimate',
'Current State',
'Created At',
'Accepted At',
'Deadline',
'Requested By',
'Owned By',
'Description',
'Note',
'Note'
]
# write pivotals header rows
pivotal_csv.writerow(headers)
# get the git issues and write the rows to the csv
git_issues = github.issues.list(git_repo, state="open")
for git_issue in git_issues:
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
story = [
'', # id
git_issue.title, # story
labels, # labels
pivotal_story_type, # story type
'', # estimate
'', # current stats
git_issue.created_at, # created at
'', # accepted at
'', # deadline
'', # requested by
'', # owned by
git_issue.body, # description
'', # note 1
'', # note 2
]
pivotal_csv.writerow(story)
if __name__ == '__main__':
run_csv()
@shyam-habarakada
Copy link

I put a more recent version of similar functionality here https://github.com/shyam-habarakada/github-to-pivotaltracker-issues - Let me know if you'd like to be added as a contributor to make any changes.

@mchoimis
Copy link

Thanks, @glenbot ! How many issues can I export at one time? Githup api v3 only let me 30 issues at a time....
@shyam-habarakada, but it's in ruby?

@glenbot
Copy link
Author

glenbot commented Apr 14, 2014

For some reason I never got notifications for these comments so sorry about the very late replies. @shyam-habarakada sure that would be nice.

@mchoimis I'm not sure, I think when I wrote this it was on an earlier version of this apt. That said, you can always run it in a generator to request the next "30" until you are done.

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