spectrochempy.pathclean¶
- pathclean(paths)[source]¶
Clean a path or a series of path in order to be compatible with windows and unix-based system.
- Parameters
paths (str or a list of str) – Path to clean. It may contain windows or conventional python separators.
- Returns
out (a pathlib object or a list of pathlib objects) – Cleaned path(s)
Examples
>>> from spectrochempy.utils 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’