-
-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathloadDb.py
More file actions
53 lines (49 loc) · 1.17 KB
/
loadDb.py
File metadata and controls
53 lines (49 loc) · 1.17 KB
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
47
48
49
50
51
52
53
import sys
import json
sys.path.insert(0,'.')
from pyminsky import minsky, DataSpec
minsky.databaseIngestor.db.connect("sqlite3","db=citibike.sqlite","citibike")
# sys.argv[0] is this script name
filenames=sys.argv[1:]
# set up spec for Citibike
spec=minsky.databaseIngestor.spec
spec.dataRowOffset(1)
spec.dataCols([0])
spec.dimensionCols([1,4,8,11,12,13,14])
spec.dimensionNames([
"tripduration",
"starttime",
"stoptime",
"start station id",
"start station name",
"start station latitude",
"start station longitude",
"end station id",
"end station name",
"end station latitude",
"end station longitude",
"bikeid",
"usertype",
"birth year",
"gender"
])
spec.dimensions([
{"type":"value"},
{"type":"time"},
{"type":"time"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"string"},
{"type":"time"},
{"type":"string"}
])
spec.dontFail(True)
minsky.databaseIngestor.db.createTable(filenames[0])
minsky.databaseIngestor.importFromCSV(filenames)