Created
June 12, 2017 16:18
-
-
Save treyssatvincent/7257049b3bbc2fdbba8a6cfbb6ab0207 to your computer and use it in GitHub Desktop.
convert csv to rb database
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
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