Skip to content

GitLab

  • Menu
Projects Groups Snippets
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A aisdb
  • Project information
    • Project information
    • Activity
    • Labels
    • Planning hierarchy
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 6
    • Issues 6
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Infrastructure Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • public_projects
  • aisdb
  • Issues
  • #16

Closed
Open
Created Jul 29, 2022 by Jay Kumar@jaykumarr

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']
Assignee
Assign to
Time tracking