Creating Database From CSV
Hi,
I am trying to create a new database from the given CSV file. However, it is not creating new table and decoding the messages.
Code
def create_db_from_csv(list_of_raw_files = ['/data/jayk/vanice_proj/test_data_20210701.csv'], db_connection_path = '/data/jayk/ais/test_data_20210701.db'):
with DBConn() as dbconn:
dbconn.attach(db_connection_path)
decode_msgs(
dbconn=dbconn,
filepaths=list_of_raw_files,
dbpath=db_connection_path,
source='TESTING',
vacuum=False
)
# creating new table
sqlite_createtable_dynamicreport(dbconn, month="202107", dbpath=db_connection_path)
aggregate_static_msgs(dbconn, ["202107"])
curr = dbconn.cursor()
curr.execute("SELECT name FROM sqlite_schema WHERE type='table' ORDER BY name;")
rows = curr.fetchall()
temp = [row['name'] for row in rows]
print(temp)
Output
found matching checksum, skipping /data/jayk/vanice_proj/test_data_20210701.csv
CREATE TABLE IF NOT EXISTS test_data_20210701.ais_202107_dynamic (
mmsi INTEGER NOT NULL,
time INTEGER NOT NULL,
longitude REAL NOT NULL,
latitude REAL NOT NULL,
rot REAL,
sog REAL,
cog REAL,
heading REAL,
maneuver TEXT,
utc_second INTEGER,
source TEXT NOT NULL,
PRIMARY KEY (mmsi, time, longitude, latitude, sog, cog, source)
) WITHOUT ROWID, STRICT;
aggregating static reports into test_data_20210701.static_202107_aggregate...
['coarsetype_ref']