write_to_file#
- caf.cvt.data_cleaning.write_to_file(data, output_path, mode='w', layer=None)[source]#
Write a DataFrame or GeoDataFrame to a file.
This function ensures the output directory exists, checks that the input DataFrame is not empty, and writes the data to the given path. Supports formats CSV, GPKG, and SHP.
- Parameters:
data (pandas.DataFrame or geopandas.GeoDataFrame) – The input data to write. Must be a GeoDataFrame for GIS formats.
output_path (pathlib.Path) – Full path including filename and extension where the file will be saved.
mode (str, optional) – File writing mode, “w” for write (default) or “a” for append.
layer (str or None, optional) – Name of the layer to write to for GIS formats. Required for GPKG, ignored for CSV.
- Return type:
None