"""Read data from a CSV file."""

import pandas as pd
from digi_leap.pylib import util, db


def read(args):
    """Read data from a CSV file."""
    reader = pd.read_csv(
        args.input_file, chunksize=util.BATCH_SIZE, na_filter=False, dtype=str)

    for i, df in enumerate(reader, 1):
        print(f'Importing chunk {i}')
        args.column = df.columns if args.all_columns else args.column

        with db.connect(args.db) as cxn:
            df.loc[:, args.column].to_sql(
                db.RAW_TABLE, cxn, if_exists='replace', index=False)

"""Read data from a CSV file."""

import pandas as pd
from digi_leap.pylib import util, db


def read(args):
    """Read data from a CSV file."""
    reader = pd.read_csv(
        args.input_file, chunksize=util.BATCH_SIZE, na_filter=False, dtype=str)

    for i, df in enumerate(reader, 1):
        print(f'Importing chunk {i}')
        args.column = df.columns if args.all_columns else args.column

        with db.connect(args.db) as cxn:
            df.loc[:, args.column].to_sql(
                db.RAW_TABLE, cxn, if_exists='replace', index=False)

Read data from a CSV file. Read data from a CSV file.