Skip to content

Instantly share code, notes, and snippets.

@sturgle
Created June 23, 2015 09:02
Show Gist options
  • Save sturgle/e6a0d2c870cfbe0423fe to your computer and use it in GitHub Desktop.
Save sturgle/e6a0d2c870cfbe0423fe to your computer and use it in GitHub Desktop.
split large sql files into small ones
fin = open('Downloads/sub.sql', 'r')
cnt = 0
fcnt = 0;
fout = open('output/out_' + `fcnt` + '.sql', 'w');
with fin as ins:
for line in ins:
cnt = cnt + 1
fout.write(line)
if line.startswith("commit") and cnt > 50000:
fout.close()
cnt = 0
fcnt = fcnt + 1
fout = open('output/out_' + `fcnt` + '.sql', 'w')
fin.close()
fout.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment