Renaming a dataset using Python API

stephanetram
stephanetram Registered Posts: 3
edited July 16 in Using Dataiku

Dear Community,

I am trying to rename a dataset from a project using the python API using the rename method from the dataikuapi.dss.dataset.DSSDataset class (https://developer.dataiku.com/latest/api-reference/python/datasets.html#dataikuapi.dss.dataset.DSSDataset.rename) but I get an

AttributeError: 'DSSDataset' object has no attribute 'rename'

How can I rename a dataset using the python API?

Here is the code I am trying:

client = dataiku.api_client()
project = client.get_default_project()
dataset_infos = [(dataset['smartName'], dataset['type']) for dataset in project.list_datasets()]
for dataset_name, dataset_type in dataset_infos:
    name = re.sub(r'LAYER\d{1}_?', '', dataset_name)
    if name[:5]!='temp_':
        name = 'temp_'+name
    if name!=dataset_name:
        dataset = project.get_dataset(dataset_name)
        dataset.rename(name)

Many Thanks for your help

Tagged:

Best Answer

Answers

Setup Info
    Tags
      Help me…