Skip to content

FileExistsError(path) Source

Bases: NumdaplotError, builtins.FileExistsError

Raised when a Table is written to a path where a file exists and on_conflict is Conflict.ERROR.

It is also a Python FileExistsError, so code catching the Python error keeps working.

Added in version 0.1.0

Parameters:

  • path (str)

    The path of the file, as given.

Attributes:

  • path

    The path of the file, as given.

Examples:

import tempfile
from pathlib import Path
import numdaplot as ndp

path = Path(tempfile.mkdtemp()) / "prices.csv"
prices = ndp.Table.from_arrays({"price": ndp.Array.from_list([1.5])})
prices.to_csv(path)
try:
    prices.to_csv(path)
except ndp.FileExistsError as error:
    print(error)
# A file already exists at .../prices.csv, pass on_conflict=ndp.Conflict.REPLACE to overwrite it.
prices.to_csv(path, on_conflict=ndp.Conflict.REPLACE)