Created
March 2, 2015 16:29
-
-
Save sephraim/252c0b06c9e424ab82ab to your computer and use it in GitHub Desktop.
Convert a TSV (tab-separated values) file to a CSV (comma-separated values) 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
#!/bin/sh | |
# Convert a TSV (tab) file to a CSV (comma) file | |
# | |
# Please note that this will surround all values with | |
# double-quotes. All other double-quotes will be escaped. | |
# | |
# Example usage: | |
# ./tab2csv.sh myfile.tsv > myfile.csv | |
sed 's/"/\\"/g' $1 \ | |
| sed $'s/\t/","/g' \ | |
| sed 's/^/"/g' \ | |
| sed 's/$/"/g' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment