pyjacket.filetools
- class pyjacket.filetools.FileManager(src_root: str = None, dst_root: str = None, rel_path: str = '', base: str = '', CSV_SEP: str = ';')[source]
Bases:
objectMake it easy to read/write files
- property dst_folder
- dst_path(filename: str = '', folder: str = '')[source]
Absolute path to a file in the dst directory
- iter_dir(folder: str = '', ext: str = None, dst=False, nat=True, exclude: set = None, **kwargs)[source]
Obtain files/folders in the <root>/<rel_path>/<folder>
- ext: types of files to return
None: yield all file types
‘/’: yield directories only
‘.png’: yield only png.
- read(filename: str, *args, folder: str = '', dst: bool = False, **kwargs)[source]
Read files of a standard format such as .txt
- read_before(filename: str, folder: str, dst: bool, valid_extensions: list)[source]
Prepare the filepath for reading a file
filename: str
folder: str
dst: bool
- valid_extensions: list
the first element of this list will be used as default.
- read_csv(filename: str, folder: str = '', dst: bool = False, **kwargs) DataFrame[source]
Read csv data into a pandas dataframe
- read_img(filename: str, folder='', dst=False, **kwargs)[source]
Read image data into a numpy.ndarray of shape: (frames, t, y, x, channels)
- read_img_meta(filename: str, folder='', dst_folder=False)[source]
Get the Exif (meta)data for an image file. This contains various acquisition details such as exposure time
- read_pickle(filename: str, folder: str = '', dst: bool = False, **kwargs)[source]
Read a python object from a pickle file.
- dst_folder: bool
read a file in the dst path rather than the src path
- savefig(filename, handle=None, folder='', close=True, **kwargs)[source]
Called ‘save’ rather than ‘write’ because the original data cannot be retrieved from the file.
- property src_folder
- src_path(filename: str = '', folder: str = '')[source]
Absolute path to a file in the src directory
- write(filename: str, data: Writeable, *args, folder: str = '', **kwargs)[source]
Writes any object that implements a write function
- write_before(filename: str, folder: str, valid_extensions: list)[source]
Finds the absolute path and creates folders when necessary
- write_csv(filename: str, data: DataFrame, folder: str = '', **kwargs)[source]
Save a csv data to a csv file
- write_img(filename: str, data: ndarray, folder: str = '', **kwargs)[source]
Write numpy.ndarray data to img file format
TODO: allow log scale display