Last active
June 21, 2022 17:56
-
-
Save albertywu/fc3203efb493df8236a4b66b3f41acf7 to your computer and use it in GitHub Desktop.
sqlcsv - run sql on your csv
This file contains hidden or 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
| # Usage: | |
| # sqlcsv foo.csv foo 'select count(*) from foo;' | |
| # | |
| # Requirement: | |
| # brew install sqlite | |
| function sqlcsv { | |
| local file="$1" | |
| local table="$2" | |
| local cmd="$3" | |
| sqlite3 :memory: -cmd '.mode csv' -cmd ".import $file $table" -cmd '.mode column' "$cmd" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment