TableSaver ========================== .. py:class:: petpal.io.table.TableSaver(saver: Optional[collections.abc.Callable[[pandas.DataFrame, str], None]] = None) Class for saving Pandas Database objects as CSV or TSV files based on a provided path. - Default behavior writes atomically (write temp file + os.replace) to avoid partial files. - Accepts an injectable writer callable for testing or alternative persistence backends. .. rubric:: Example .. code-block:: python import pandas as pd from petpal.io.table import TableSaver table_saver = TableSaver() my_data = pd.DataFrame(data={'time': [0, 1, 2], 'value': [1, 4, 9]}) # when file extension is .csv, uses commas to separate values table_saver.save(my_data, 'table.csv') # when file extension is .tsv or .txt, uses tabs to separate values table_saver.save(my_data, 'table.txt') :ivar _saver: Injectable tabular data saving function that saves a dataframe to a file. .. py:method:: _atomic_save(df: pandas.DataFrame, path: str) Saves the data from a Pandas DataFrame object as a tabular file, such as CSV or TSV. :param df: Pandas DataFrame with data to be saved. :type df: pd.DataFrame :param path: Path to file where data is saved. :type path: str .. py:method:: save(df: pandas.DataFrame, path: str) -> None API that applies the table saving function assigned to `self._saver`. :param df: Pandas DataFrame with data to be saved. :type df: pd.DataFrame :param path: Path to file where data is saved. :type path: str