nwm_region_mgr.utils.io_utils.read_table_safely#

nwm_region_mgr.utils.io_utils.read_table_safely(file_path, quotechar='"', escapechar='\\\\', fallback_encodings=['utf-8', 'utf-8-sig', 'latin1', 'cp1252'], dtype=None)[source]#

Read a delimited text file (CSV/TSV) safely.

Return type:

DataFrame

With: 1. Automatic encoding detection.
  1. Automatic delimiter detection.

  2. Optional dtype specification.

  3. Fallback encodings if decoding fails.

Parameters:
  • file_path – str Path to the file.

  • quotechar – str Character used to quote fields.

  • escapechar – str Character used to escape quotechar inside quoted fields.

  • fallback_encodings – list[str] Encodings to try if detection fails.

  • dtype – dict, optional Column name to dtype mapping (like in pd.read_csv).

Returns:

pd.DataFrame

Loaded DataFrame.