/gist:c291f35afb8d27073972 Secret
Last active
August 29, 2015 14:23
-
-
Save bnagy/c291f35afb8d27073972 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
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