-
-
Save anonymous/ceb862287b78a2368c6e to your computer and use it in GitHub Desktop.
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
input = File.open("states_and_gs_IDs.txt") | |
output = File.open("script.sh","w") | |
headers = {} | |
state_code = {} | |
gs_id = {} | |
input.readlines.each_with_index do |line, index| | |
fields = line.chomp.split("\t") | |
###MAKE HEADERS | |
if index == 0 | |
fields.each_with_index do |field,col_num| | |
headers[field] = col_num | |
end | |
next | |
end | |
###READ DATA INTO MEMORY | |
gs_id = fields[headers["id"]] | |
state_code = fields[headers["state"]].downcase | |
end | |
headers.each do |headers| | |
output.write("update _#{state_code}.school set active = 0 where id in \(#{gs_id});\n\n") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment