Convert a CSV file to a Markdown table using SQLite3
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/bash | |
#remove old output fiile | |
outputFile="$1.md" | |
rm -f outputFile | |
#SQLite3 commands | |
cmd=$({ grep -v '^#' <<EOF | |
.headers on | |
.mode csv | |
drop table if exists temp_csvFile; | |
.import $1 temp_csvFile | |
.mode markdown | |
.headers on | |
.output $outputFile | |
select * from temp_csvFile; | |
EOF | |
}) | |
#Pipe commands to temporary database | |
echo -e "$cmd" | sqlite3 '' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment