diff options
author | elioat <{ID}+{username}@users.noreply.github.com> | 2024-10-11 11:31:30 -0400 |
---|---|---|
committer | elioat <{ID}+{username}@users.noreply.github.com> | 2024-10-11 11:31:30 -0400 |
commit | 217b86ebc9a12d118d8fdc20507a0f2381750c09 (patch) | |
tree | 6143222855b81ae4a8128dd8a57100d63f11b135 | |
parent | b0ae59ef398e851e680f050f2f0ada82c8f8277c (diff) | |
download | tour-217b86ebc9a12d118d8fdc20507a0f2381750c09.tar.gz |
*
-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 |