Last active
January 1, 2023 23:09
-
-
Save log4code/079d1d1f02ea2c766951b220ce5b23f5 to your computer and use it in GitHub Desktop.
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