Last active
October 13, 2020 13:24
-
-
Save jelly/fd1027a7712cdb0c457e9b09763ea6b6 to your computer and use it in GitHub Desktop.
Export Github issues as CSV for import into Gitlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
""" | |
Export Github issues to CSV for import into Gitlab. | |
""" | |
import argparse | |
import csv | |
import requests | |
def main(url, filename): | |
req = requests.get(url) | |
data = req.json() | |
with open(filename, 'w') as csvfile: | |
writer = csv.writer(csvfile, quoting=csv.QUOTE_MINIMAL) | |
writer.writerow(['title', 'description']) | |
for row in data: | |
writer.writerow([row['title'], row['body']]) | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser(description="Write GitHub repository issues to CSV file to import into Gitlab") | |
parser.add_argument('--org', type=str, help="Organisation or username") | |
parser.add_argument('--repo', type=str, help="Repository name") | |
parser.add_argument('--filename', type=str, help="Filename to write CSV output to") | |
args = parser.parse_args() | |
url = "https://api.github.com/repos/{}/{}/issues?state=open".format(args.org, args.repo) | |
main(url, args.filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment