-
-
Save anonymous/8e8bb7f376fce8d3cef1 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
#!/usr/bin/ruby | |
ids=[] | |
ids_t=[] | |
ids_t = File.readlines("id_to_change_uniq") | |
ids=ids_t.map(&:chomp) | |
new_id="" | |
file2 = open("dump-to-database-test-1", 'w') | |
File.open("test.sql").each do |line| | |
if ( id = ids.find { |w| line =~ /\b#{w}\b/ } ) | |
new_id = id.to_i + 1000 | |
line.gsub!(/\b#{id}\b/,"#{new_id}") | |
file2.write(line) | |
else | |
file2.write(line) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment