Customise supported formats
By default, the extensions supported by the loader/saver the following: csv, docx, jpg, json, md, parquet, pdf, pickle, png, pptx, sql, toml, txt, xlsx, xml, yaml, yml.
However, through the extra_loader_config
and extra_saver_config
parameters, Easy Environment allows you to customise any file format and integrate it into the tool.
Create a loader/saver function: create a loader or saver function for the corresponding extension.
A load function must contain the path argument, which represents the path to the file. It is also recommanded to pass a **kwargs
arguments in order to allows greater flexibility when calling the loader though the EasyEnvironment instance.
A save function must contain the path
and obj
arguments, representing respectively the object to be saved and the access path to which to save.
Initialise Easy Environment: create an instance of the EasyEnvironment class by specifying your loader and/or saver functions.
Loader and saver functions must be specified by a dictionnary in which the keys correspond to the extensions and the values correspond to a tuple. The tuple contains two elements : the created function and a string representing the reading/writing mode (either "rb" or "rt" for a loader / either "wb" or "wt" for a saver).
Example of customisation:
In the above example, you can specify custom loader and saver functions for file extensions not covered by the default configurations. Just replace txt_loader_function
and txt_saver_function
with your own loader and saver functions, respectively.
Make sure to import the necessary functions and libraries for your custom loaders and savers.
Other examples of loader/saver functions are available in Source Code.
Last updated