Created
January 27, 2012 09:53
-
-
Save stuartloxton/1688035 to your computer and use it in GitHub Desktop.
Split PHPMyAdmin export into individual tables.
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
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