src/file-utils/edfi_lms_file_utils/file_reader.py
def _read_csv(
    file: str,
    nrows: Optional[int] = None,
    data_types: Dict[str, str] = dict(),
    extra_date_columns: List[str] = list(),
) -> pd.DataFrame:
    """
    Loads a CSV file into a DataFrame.

    Parameters
    ----------
    file: str
        Full path to the file to read.
    nrows: int (optional)
        Number of rows to read. If not specified, reads all lines.
    data_types: dictionary (optional)
        A dictionary for forcing Pandas to use the correct data
        type. Do not use for DateTime columns - instead add those
        columns to the list in the `extra_date_columns` parameter.
    extra_date_columns: list (optional)
        A list of columns that should be treated as having DateTime
        data type.

    Returns
    -------
    pd.DataFrame
        The exact columns depend on the file being read.
    """

    logger.debug(f"Reading file: {file}")
    if file:

        dates = [
            "SourceCreateDate",
            "SourceLastModifiedDate",
            "CreateDate",
            "LastModifiedDate",
            *extra_date_columns,
        ]

        dtype = {
            "SourceSystemIdentifier": "string",
            "SourceSystem": "string",
            **data_types,
        }

        return pd.read_csv(
            file,
            engine="c",
            parse_dates=dates,
            infer_datetime_format=True,
            nrows=nrows,
            dtype=dtype,
        )

    return _default()

    Loads a CSV file into a DataFrame.

    Parameters
    ----------
    file: str
        Full path to the file to read.
    nrows: int (optional)
        Number of rows to read. If not specified, reads all lines.
    data_types: dictionary (optional)
        A dictionary for forcing Pandas to use the correct data
        type. Do not use for DateTime columns - instead add those
        columns to the list in the `extra_date_columns` parameter.
    extra_date_columns: list (optional)
        A list of columns that should be treated as having DateTime
        data type.

    Returns
    -------
    pd.DataFrame
        The exact columns depend on the file being read.
    
Loads a CSV file into a DataFrame.
Parameters

str
Full path to the file to read.
nrows: int (optional)
Number of rows to read. If not specified, reads all lines.
data_types: dictionary (optional)
A dictionary for forcing Pandas to use the correct data
type. Do not use for DateTime columns - instead add those
columns to the list in the `extra_date_columns` parameter.
extra_date_columns: list (optional)
A list of columns that should be treated as having DateTime
data type.

Returns

pd.DataFrame
The exact columns depend on the file being read.
Loads a CSV file into a DataFrame . Parameters str Full path to the file to read . nrows : int ( optional ) Number of rows to read . If not specified reads all lines . data_types : dictionary ( optional ) A dictionary for forcing Pandas to use the correct data type . Do not use for DateTime columns - instead add those columns to the list in the ` extra_date_columns ` parameter . extra_date_columns : list ( optional ) A list of columns that should be treated as having DateTime data type . Returns pd . DataFrame The exact columns depend on the file being read .
def _read_csv(
    file: str,
    nrows: Optional[int] = None,
    data_types: Dict[str, str] = dict(),
    extra_date_columns: List[str] = list(),
) -> pd.DataFrame:
    logger.debug(f"Reading file: {file}")
    if file:
        dates = [
            "SourceCreateDate",
            "SourceLastModifiedDate",
            "CreateDate",
            "LastModifiedDate",
            *extra_date_columns,
        ]
        dtype = {
            "SourceSystemIdentifier": "string",
            "SourceSystem": "string",
            **data_types,
        }
        return pd.read_csv(
            file,
            engine="c",
            parse_dates=dates,
            infer_datetime_format=True,
            nrows=nrows,
            dtype=dtype,
        )
    return _default()
def _read_csv ( file : str , nrows : Optional [ int ] = None , data_types : Dict [ str , str ] = dict ( ) , extra_date_columns : List [ str ] = list ( ) , ) -> pd . DataFrame : logger . debug ( f"Reading file: {file}" ) if file : dates = [ "SourceCreateDate" , "SourceLastModifiedDate" , "CreateDate" , "LastModifiedDate" , * extra_date_columns , ] dtype = { "SourceSystemIdentifier" : "string" , "SourceSystem" : "string" , ** data_types , } return pd . read_csv ( file , engine = "c" , parse_dates = dates , infer_datetime_format = True , nrows = nrows , dtype = dtype , ) return _default ( )
Loads a CSV file into a DataFrame.
Loads a CSV file into a DataFrame .
"""
    Loads a CSV file into a DataFrame.

    Parameters
    ----------
    file: str
        Full path to the file to read.
    nrows: int (optional)
        Number of rows to read. If not specified, reads all lines.
    data_types: dictionary (optional)
        A dictionary for forcing Pandas to use the correct data
        type. Do not use for DateTime columns - instead add those
        columns to the list in the `extra_date_columns` parameter.
    extra_date_columns: list (optional)
        A list of columns that should be treated as having DateTime
        data type.

    Returns
    -------
    pd.DataFrame
        The exact columns depend on the file being read.
    """
file
str
nrows
Optional[int]
data_types
Dict[str, str]
extra_date_columns
List[str]