Exporting github issues to csv

I’m trying to export a list of github issues from a repository to csv, but i keep coming across a few errors. I’ve tried looking into it on other questions but they didn’t seem to help me out. I’m currently using python2.7.9 on SLES12 vm.

def write_issues(response):
    for issue in response.json():
        labels = issue['labels']
        for label in labels:
            if label['name'] == "Client Requested":
                csvout.writerow([issue['number'],
                issue['title'].encode('utf-8'),
                issue['body'].encode('utf-8'),
                issue['created_at'],
                issue['updated_at']])

getting these errors

  • How do I generate a git commit log for the last month, and export it as CSV?
  • How do I get git to ignore my csv files?
  • Import encrypted csv into Python 3
  • How to write to CSV file in Javascript
  • How to do a bash foreach csv field to 'git submodule add'
  • SVN - reject, change and revert to previous version
  • Traceback (most recent call last):
      File "export.py", line 50, in <module>
        write_issues(r)
      File "export.py", line 24, in write_issues
        labels = issue['labels']
    TypeError: string indices must be integers
    

  • Is there implementation of Git in pure Python?
  • fatal: git write-tree failed to write a tree
  • How does section of .gitconfig work?
  • How to check if a git commit author is valid
  • Authentication in gitpython
  • Why does git:// works but git@ does not
  • One Solution collect form web for “Exporting github issues to csv”

    response.json() definitely doesn’t contain a list of “issue” dictionaries. You are either making a request to an invalid or incorrect endpoint, or hitting a rate limit. Check an actual value of response.json() before the loop.

    Works for me:

    >>> import requests
    >>> 
    >>> url = "https://api.github.com/repos/angular/protractor/issues"
    >>> response = requests.get(url)
    >>> for issue in response.json():
    ...     labels = issue['labels']
    ...     for label in labels:
    ...         print label
    ... 
    {u'url': u'https://api.github.com/repos/angular/protractor/labels/type:%20docs', u'color': u'5319e7', u'name': u'type: docs'}
    {u'url': u'https://api.github.com/repos/angular/protractor/labels/type:%20question', u'color': u'f7c6c7', u'name': u'type: question'}
    {u'url': u'https://api.github.com/repos/angular/protractor/labels/type:%20feature%20request', u'color': u'009800', u'name': u'type: feature request'}
    ...
    
    Git Baby is a git and github fan, let's start git clone.