Created
May 14, 2013 19:47
-
-
Save danidiaz/5578909 to your computer and use it in GitHub Desktop.
Dividing a postgresql database dump.
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
currfile = nil | |
File.open("postgresql.dmp", "r") do |file_handle| | |
file_handle.each_line do |line| | |
if line =~ /^COPY (\S+) / | |
currfile.close unless currfile.nil? | |
currfile = File.open("./postgresql_parts/#{$1}.dmp","w") | |
end | |
currfile.puts(line) unless currfile.nil? | |
end | |
end | |
currfile.close unless currfile.nil? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment