Last active
August 29, 2015 14:05
-
-
Save philippgeisler/ede5d55ce0ff92a189dc to your computer and use it in GitHub Desktop.
Should create one .csv for each table CREATEd in a MySQL export. Result might be dependent on export parameters, this has been tested for only one particular export file.
This file contains 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
#!/usr/bin/awk -f | |
BEGIN { RS=";\n"; } | |
{ | |
if ( $1 == "CREATE" ) { | |
fn = substr($3,2,length($3)-2) ".csv"; | |
print fn > fn; | |
} | |
if ( $1 == "INSERT" ) { | |
iv = index($0,"(")+1; | |
print substr($0,iv,length($0)-iv) >> fn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment