Last active
December 24, 2015 10:09
-
-
Save hoosteeno/6781738 to your computer and use it in GitHub Desktop.
Python script for creating sql from healthy dialog spreadsheet.
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 | |
""" | |
* There is no need to run this per location; you can concatenate all input files or all output files. | |
* Modify line 15 with input filename | |
* Direct stdout to output filename (a .sql file) | |
* Work with DBAs (oncall if necessary) to get this done: https://bugzilla.mozilla.org/show_bug.cgi?id=922340 | |
Example output: | |
UPDATE profile, auth_user SET profile.dialog = '14,7,36' WHERE profile.user_id = auth_user.id AND auth_user.username = 'foo'; | |
""" | |
lines = [] | |
with open("santaclara_dialog_20131030.csv", "rU") as f: | |
lines = f.readlines() | |
for line in lines: | |
a = line.rstrip().split(',') | |
username = a[0] | |
dialog = ','.join(a[1:]).strip('"') | |
print ("UPDATE profile, auth_user SET profile.dialog = '%s' " | |
"WHERE profile.user_id = auth_user.id " | |
"AND auth_user.username = '%s';" % (dialog, username)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment