Extract dataset parameters

ExtractDatasetParameters.py

from datetime import datetime, timedelta

from LOGS import LOGS
from LOGS.Entities import DatasetRequestParameter

# Connect to LOGS
logs = LOGS()

# Search for datasets with meta data that contain this string, including the parameters
for dataset in logs.datasets(
    DatasetRequestParameter(
        formatIds=["UXcknYrJ"],  # id of the format "NMR (Bruker)"
        includeParameters=True,  # Include the parameters in the results datasets. Alternatively,
        # you can also use the .fetchParameters() method on the dataset object to fetch the parameters later.
        enteredFrom=datetime.now() - timedelta(days=14),
    )
):
    # The dataset object has a .parameters attribute that is a flattened dictionary representation of the
    # parameters in the UI. To find the parameter name for the parameters your are looking for, you can
    # use e.g. print the dataset.parameters.keys() to see all the parameter names in the dataset.
    # Alternatively, the parameter tree can also be accessed via the .parameterTree
    # attribute, which is a tree representation of the parameters much like in the UI. Keep in mind the the
    # parameter tree is less efficient to fetch and should only be used if the tree structure is required.
    if dataset.parameters and "General information/Duration" in dataset.parameters:
        print(
            f"Dataset '{dataset.name}' ({dataset.id}) General information/Duration = {dataset.parameters['General information/Duration']}"
        )