about summary refs log tree commit diff stats
path: root/py/air-quality/convert-csv-2-sqlite.sh
blob: 1b493cf05866824136755e72b0a6c0a479b15340 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/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


sqlite3 airq.db <<EOF

.mode csv
.import export.csv air
SELECT * FROM air;
.exit

EOF