select files with regex on project level

Sarthak
Sarthak Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 15 ✭✭✭

Hi,

How to create a list of datasets matching a keyword using python API? Need to know this as a part of some project.

Regards

Best Answer

  • Zach
    Zach Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 153 Dataiker
    edited July 17 Answer ✓

    Hi @s_dravid
    ,

    The following code will list all datasets in the flow where the name of the dataset contains the word "KEYWORD":

    import dataiku
    import dataikuapi
    
    client = dataiku.api_client()
    project = client.get_default_project()
    flow = project.get_flow()
    graph = flow.get_graph()
    
    for item in graph.get_items_in_traversal_order(as_type="object"):
        if not isinstance(item, dataikuapi.dss.dataset.DSSDataset):
            # Skip items that aren't a dataset
            continue
            
        if "KEYWORD" in item.name:
            print("Found dataset with keyword:", item.name)

    Thanks,

    Zach

Answers

Setup Info
    Tags
      Help me…