Skip to content

Instantly share code, notes, and snippets.

@stuartloxton
Created January 27, 2012 09:53
Show Gist options
  • Save stuartloxton/1688035 to your computer and use it in GitHub Desktop.
Save stuartloxton/1688035 to your computer and use it in GitHub Desktop.
Split PHPMyAdmin export into individual tables.
import sys
f = open(sys.argv[1])
files = f.read().split('-- --------------------------------------------------------')
files.pop(0)
for file in files:
# Find table name
name_index = file.index("for table `") + 11
name_end = file.index("`", name_index)
table = file[name_index:name_end]
f = open('./' + table + '.sql', 'w')
f.write(file)
f.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment