read_csv

getml.sqlite3.read_csv(conn, fnames, table_name, header=True, if_exists='append', quotechar='"', sep=',', skip=0, colnames=None)[source]

Reads a list of CSV files and writes them into an sqlite3 table.

Args:
conn (sqlite3.Connection):

A sqlite3 connection created by connect().

fnames (str or List[str]):

The names of the CSV files.

fnames (str or List[str]):

The names of the CSV files.

table_name (str):

The name of the table to write to.

header (bool):

Whether the csv file contains a header. If True, the first line is skipped and column names are inferred accordingly.

quotechar (str):

The string escape character.

if_exists (str):

How to behave if the table already exists:

  • ‘fail’: Raise a ValueError.

  • ‘replace’: Drop the table before inserting new values.

  • ‘append’: Insert new values to the existing table.

sep (str):

The field separator.

skip (int):

The number of lines to skip (before a possible header)

colnames(List[str] or None, optional):

The first line of a CSV file usually contains the column names. When this is not the case, you can explicitly pass them. If you pass colnames, it is assumed that the CSV files do not contain a header, thus overriding the ‘header’ variable.