select files with regex on project level

Solved!
s_dravid
Level 3
select files with regex on project level

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

0 Kudos
1 Solution
ZachM
Dataiker

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

View solution in original post

0 Kudos
2 Replies
ZachM
Dataiker

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

0 Kudos
s_dravid
Level 3
Author

Thanks for the help!

0 Kudos