How to assign input file name to a variable dynamically in python recipe

Options
NilamberPanda
NilamberPanda Partner, Dataiku DSS Core Designer, Dataiku DSS Core Concepts, Registered Posts: 9 Partner

Hi,

I am creating a flow where a User will upload csv files everytime they use my flow. I want to dynamically store this filename in a variable and use in my python code. How can I store the filename dynamically in a variable ?


Operating system used: Windows

Answers

  • fchataigner2
    fchataigner2 Dataiker Posts: 355 Dataiker
    edited July 17
    Options

    Hi,

    if "upload" in this context means "upload in a UploadedFiles dataset", then you can get the names of the files in such a dataset with a few lines of python

    import dataiku
    ds = dataiku.Dataset('the_name_of_the_dataset')
    file_paths = [p['path'] for p in ds.get_files_info()['globalPaths']]

    and file_paths will be the '/'-prefixed list of names of files in the dataset

Setup Info
    Tags
      Help me…