.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/resolve_local_test_path.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note You can download :ref:`below ` the full example code. and run it online in `Codespaces `__ .. image:: https://github.com/codespaces/badge.svg :target: https://codespaces.new/spark-cleantech-l3/sda-copy?quickstart=1 --- .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_resolve_local_test_path.py: Resolve a test name to its local folder path. ============================================== :func:`~sda.api.file_discovery.resolve_local_test_path` translates a canonical test identifier (e.g. ``"T297"``) into the local :class:`~pathlib.Path` of the folder that contains its raw data files, as configured in ``~/sda.json``. This is the same resolution step that :func:`~sda.api.load.load_test` performs internally before reading any data. Call it directly when you need the folder path itself — for example to list all files, open the folder in a file manager, or pass the path to another tool. See Also -------- :func:`~sda.api.file_discovery.discover_data_file` : Find the specific Excel file inside the resolved folder. :func:`~sda.api.load.load_test` : High-level function that calls ``resolve_local_test_path`` internally. .. GENERATED FROM PYTHON SOURCE LINES 23-28 Resolve a single test name. ---------------------------- Pass a canonical test ID such as ``"T297"`` and get back the :class:`~pathlib.Path` of the folder that holds its data files. .. GENERATED FROM PYTHON SOURCE LINES 28-35 .. code-block:: Python from sda.api.file_discovery import discover_data_file, resolve_local_test_path folder = resolve_local_test_path("T297") print(f"Folder: {folder}") print(f"Exists: {folder.exists()}") .. GENERATED FROM PYTHON SOURCE LINES 36-41 List all files inside the resolved folder. ------------------------------------------ Once you have the folder path you can glob for any file type — not just the primary Excel workbook. .. GENERATED FROM PYTHON SOURCE LINES 41-47 .. code-block:: Python xlsx_files = list(folder.glob("*.xls*")) print(f"Excel files in {folder.name}:") for f in xlsx_files: print(f" {f.name}") .. GENERATED FROM PYTHON SOURCE LINES 48-53 Combine with ``discover_data_file`` to get the exact file path. --------------------------------------------------------------- :func:`~sda.api.file_discovery.discover_data_file` picks the unique matching workbook from the folder returned by ``resolve_local_test_path``. .. GENERATED FROM PYTHON SOURCE LINES 53-56 .. code-block:: Python data_file = discover_data_file(folder, "T297") print(f"Data file: {data_file}") .. _sphx_glr_download_auto_examples_resolve_local_test_path.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: resolve_local_test_path.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: resolve_local_test_path.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: resolve_local_test_path.zip `