File Manipulation Tools
The File Tools module contains a number of tools used internally to open or write to data files.
Functions
|
Function that exports data from a pandas DataFrame to a .csv using a passed parent directory and name. |
|
Function to try opening a file with pandas.read_csv, passing the path and any additional positional or keyword arguments. |
|
Function that tries to open a file at path using a function passed as func. |
- chromaquant.utils.file_tools.export_to_csv(dataframe: DataFrame, parent: str, name: str = '')
Function that exports data from a pandas DataFrame to a .csv using a passed parent directory and name.
Parameters
- dataframepandas.DataFrame
Passed Pandas DataFrame.
- parentstring
Name of parent directory for exported file.
- namestring
Name of file to be exported.
Returns
None
- chromaquant.utils.file_tools.try_open_csv(path: str, *args, **kwargs) tuple[bool, Any]
Function to try opening a file with pandas.read_csv, passing the path and any additional positional or keyword arguments.
Parameters
- pathstr
Path to .csv file.
Returns
- tf: bool
A Boolean indicating whether file could be opened (True) or not (False).
- data: Any
The data read from the file at path.
- chromaquant.utils.file_tools.try_open_file(func: Callable[[...], Any], path: str, *args, **kwargs) tuple[bool, Any]
Function that tries to open a file at path using a function passed as func.
Parameters
- funcCallable[…, Any]
A function that accepts a path (string) and any additional positional or keyword arguments and returns some data.
- path_type_
A full path to the data file to be opened.
Returns
- tf: bool
A Boolean indicating whether file could be opened (True) or not (False).
- data: Any
The data read from the file at path.