Skip to content

Instantly share code, notes, and snippets.

@treyssatvincent
Created June 12, 2017 16:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save treyssatvincent/7257049b3bbc2fdbba8a6cfbb6ab0207 to your computer and use it in GitHub Desktop.
Save treyssatvincent/7257049b3bbc2fdbba8a6cfbb6ab0207 to your computer and use it in GitHub Desktop.
convert csv to rb database
import csv
with open('input.csv') as f:
fieldnames = ('tag', 'label', 'description', 'user_id')
r = csv.DictReader(f, fieldnames, delimiter='|')
next(f, None) # skip header
rows = []
k = 0
for row in r:
txt = "Issue.create(tag:'" + row['tag'] + "', label:'" + row['label'] + "', description:'" + row['description'] + "' , user_id:'1')"
with open("output.rb", "a") as output_file:
output_file.write(txt)
output_file.write("\n")
print txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment