Skip to content

Instantly share code, notes, and snippets.

@bnagy
Forked from anonymous/gist:4a2dbf4babc1d007d6c0
Last active August 29, 2015 14:23
Show Gist options
  • Save bnagy/c291f35afb8d27073972 to your computer and use it in GitHub Desktop.
Save bnagy/c291f35afb8d27073972 to your computer and use it in GitHub Desktop.
ids = File.readlines("id_to_change_all_uniq").map(&:chomp)
replacements = {}
ids.each {|id| replacements[id] = (Integer(id)+ 1000).to_s}
file2 = File.open("dump-to-database-yshop", 'wb')
File.open("yshop_14-megaslice").each do |line|
possible_ids = line.scan /\d+/
possible_ids.each {|id|
if (replace = replacements[id])
line.sub! /\b#{id}\b/, replace
end
}
file2.write(line)
end
file2.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment