Skip to content

Instantly share code, notes, and snippets.

@philippgeisler
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save philippgeisler/ede5d55ce0ff92a189dc to your computer and use it in GitHub Desktop.
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.
#!/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