Skip to content

Instantly share code, notes, and snippets.

Created April 10, 2015 22:56
Show Gist options
  • Save anonymous/ceb862287b78a2368c6e to your computer and use it in GitHub Desktop.
Save anonymous/ceb862287b78a2368c6e to your computer and use it in GitHub Desktop.
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