spectrochempy.pathclean¶
- pathclean(paths)[source]¶
Clean a path or a series of path.
The aim is to be compatible with windows and unix-based system.
- Parameters
paths (
str
or alist
ofstr
) – Path to clean. It may contain Windows or conventional python separators.- Returns
pathlib or list of pathlib – Cleaned path(s).
Examples
>>> from spectrochempy.utils.file import pathclean
Using unix/mac way to write paths >>> filename = pathclean(‘irdata/nh4y-activation.spg’) >>> filename.suffix ‘.spg’ >>> filename.parent.name ‘irdata’
or Windows >>> filename = pathclean(“irdata\nh4y-activation.spg”) >>> filename.parent.name ‘irdata’
Due to the escape character in Unix, path string should be escaped \ or the raw-string prefix
r
must be used as shown below >>> filename = pathclean(r”irdatanh4y-activation.spg”) >>> filename.suffix ‘.spg’ >>> filename.parent.name ‘irdata’