-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlite_loader.sh
executable file
·46 lines (41 loc) · 1.27 KB
/
sqlite_loader.sh
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/bin/bash
input='examples/2017-10-27'
#input='examples/2017-04-26/ examples/2017-08-30/ examples/2017-09-04/'
#input='examples/2017-04-26/'
#input='one_file/'
database='activity.sqlite'
tmp=$(mktemp .data-XXXXXX)
./sqlite_loader.py ${input} > "${tmp}"
sqlite3 "${database}" <<EOF
DROP TABLE IF EXISTS activity;
CREATE TABLE activity (
SerialNo int,
RecievedTimestamp timestamptz,
RecordedAtTime timestamptz,
ValidUntilTime timestamptz,
VehicleMonitoringRef text,
LineRef text,
DirectionRef text,
DataFrameRef int,
DatedVehicleJourneyRef int,
PublishedLineName text,
OperatorRef text,
VehicleFeatureRef text,
OriginRef text,
OriginName text,
DestinationRef text,
DestinationName text,
OriginAimedDepartureTime timestamptz,
Monitored text,
InPanic text,
Longitude real,
Latitude real,
Bearing int,
Delay text,
VehicleRef text
);
.separator |
.import ${tmp} activity
SELECT count(*) FROM activity;
EOF
rm "${tmp}"