environmentaltools.common.csv

environmentaltools.common.csv(file_name: str, ts: bool = False, date_format=None, sep: str = ',', encoding: str = 'utf-8', index_col: list = [0], non_natural_date: bool = False, no_data_values: int = -999)[source]

Read CSV file with flexible datetime and encoding options.

Flexible CSV reader with support for time series data, custom separators, various encodings, and handling of non-natural date formats (e.g., 30-day months).

Parameters:
  • file_name (str) – Path to CSV file (supports .csv, .txt, .dat, .zip).

  • ts (bool) – If True, treats first column as datetime index. Defaults to False.

  • date_format (str, optional) – Date format string for parsing. Defaults to None.

  • sep (str) – Column separator character. Defaults to “,”.

  • encoding (str) – Character encoding. Defaults to “utf-8”.

  • index_col (list) – Columns to use as index. Defaults to [0].

  • non_natural_date (bool) – If True, handles model dates with 30-day months. Defaults to False.

  • no_data_values (int) – Value to treat as NaN. Defaults to -999.

Returns:

Loaded data with appropriate index type.

Return type:

pd.DataFrame