Created
July 30, 2018 03:59
-
-
Save thorvn/1cccfd2b97dd47b44732cf0d21d2ae56 to your computer and use it in GitHub Desktop.
Split big sql file
This file contains hidden or 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
filename = 'flowdata_201803052230.sql' | |
INSERT_MATCHER = 'INSERT INTO' | |
file = 1 | |
counter = 1 | |
File.open(filename, 'r').each do |line| | |
next unless line.include? INSERT_MATCHER | |
File.open(file.to_s + '.sql', 'a+') { |file| file.write("\n" + line) } | |
counter += 1 | |
if counter == 100 | |
file += 1 | |
counter = 1 | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment