code: def LoadFile(f, table_name, conn):
    
    reader = csv.reader(f)
    header = next(reader)
  
    columns = []
    for n in header:
      n = n.replace(' ', '')
      n = n.replace('-', '_')
      columns.append(n)
  
    create_columns = []
    column_types = {}
    for n in columns:
      if n in column_types:
        create_columns.append("%s %s" % (n, column_types[n]))
      else:
        create_columns.append("%s INTEGER" % (n))
  
    c = conn.cursor()
    try:
      c.execute("CREATE TABLE %s (%s)" % (table_name, ",".join(create_columns)))
    except sqlite.OperationalError:
      # Likely table exists
      print("table %s already exists?" % (table_name))
      for create_column in create_columns:
        try:
          c.execute("ALTER TABLE %s ADD COLUMN %s" % (table_name, create_column))
        except sqlite.OperationalError:
          # Likely it already exists
          print("column %s already exists in %s?" % (create_column, table_name))
  
    placeholders = ",".join(["?"] * len(columns))
    insert_values = "INSERT INTO %s (%s) VALUES (%s)" % (table_name, ",".join(columns), placeholders)
  
    #c.execute("BEGIN TRANSACTION;")
    for row in reader:
      if row:
        if len(row) < len(columns):
          row.extend([None] * (len(columns) - len(row)))
        c.execute(insert_values, row)
    #c.execute("END TRANSACTION;")
    conn.commit()
docs: Import lines from f as new table in db with cursor c.