Discover the winners & finalists of the 2022 Dataiku Frontrunner Awards!READ THEIR USE CASES

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

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

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

0 Kudos
1 Reply
fchataigner2
Dataiker

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 

0 Kudos