Skip to content

Instantly share code, notes, and snippets.

Created June 22, 2015 11:11
Show Gist options
  • Save anonymous/15b22caab60edfe9caf5 to your computer and use it in GitHub Desktop.
Save anonymous/15b22caab60edfe9caf5 to your computer and use it in GitHub Desktop.
ids_t=[]
ids_t = File.readlines("id_to_change_all_uniq")
ids=ids_t.map(&:chomp)
new_id=""
file2 = open("dump-to-database-yshop", 'w')
File.open("yshop_14-megaslice").each do |line|
if ( id = ids.find { |w| line =~ /\b#{w}\b/ } )
new_id = id.to_i + 10000
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