Skip to content

Instantly share code, notes, and snippets.

@l0neranger
Last active August 29, 2015 14:00
Show Gist options
  • Save l0neranger/ae8770d90c192aa5e6a0 to your computer and use it in GitHub Desktop.
Save l0neranger/ae8770d90c192aa5e6a0 to your computer and use it in GitHub Desktop.
Convert a tab de-limited mysql export to csv
# Strategy:
# Remove all double quotes.
# Replace all tabs with double-quotes on either side of a comma.
# Add double-quotes to the beginning and the end of the line.
# Debian
sed -e 's/\"//g' -e 's/\t/\",\"/g' -e 's/^/\"/' -e 's/$/\"/' filename.tab > filename.csv
# OS X: The \t needs to be replaced by CTRL+v followed by a tab.
sed -e 's/\"//g' -e 's/ /\",\"/g' -e 's/^/\"/' -e 's/$/\"/' filename.tab > filename.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment