Skip to content

Instantly share code, notes, and snippets.

@Kurobyte
Forked from stuartloxton/table-split.py
Last active December 13, 2015 03:30
Show Gist options
  • Select an option

  • Save Kurobyte/4c16a9849af16ad04052 to your computer and use it in GitHub Desktop.

Select an option

Save Kurobyte/4c16a9849af16ad04052 to your computer and use it in GitHub Desktop.
Split PHPMyAdmin export into individual tables.
import sys, re
f = open(sys.argv[1])
files = f.read().split('-- --------------------------------------------------------')
files.pop(0)
for file in files:
table = re.search('-- .*\`(.*)\`\n--', file).group(1) #Get table name
f = open('./' + table + '.sql', 'w')
f.write(file)
f.close()
print "--- ["+ table + "] table splited ---";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment