diff options
-rwxr-xr-x | py/air-quality/convert-csv-2-sqlite.sh | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/py/air-quality/convert-csv-2-sqlite.sh b/py/air-quality/convert-csv-2-sqlite.sh new file mode 100755 index 0000000..13c98cc --- /dev/null +++ b/py/air-quality/convert-csv-2-sqlite.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Convert CSV to SQLite + +# check for input file, abort if it is missing +if [ ! -f export.csv ]; then + echo "export.csv not found!" + exit 1 +fi + +# check for sqlite3 database, if it exists, +# delete it so we can make a new one +if [ -f airq.db ]; then + rm airq.db +fi + +# create a new sqlite3 database +# import the CSV file into the database +# display the contents of the database +# exit sqlite3 + +# make this work in a bash script + +sqlite3 airq.db <<EOF + +.mode csv +.import export.csv air +SELECT * FROM air; +.exit + +EOF \ No newline at end of file |