How to save a dataframe as a csv in a managed folder?
Hi all,
I want to save a dataframe as a csv in a managed folder inside my Dataiku project.
To read files from the managed folder, I usually use this code (because my script is deployed as an API inside Dataiku)
folder_path = folders[0]
path_of_file = os.path.join(folder_path, "file_name_with_extension")
df = pd.read_csv(path_of_file)
But how about saving a dataframe as a csv in the managed folder?
Can someone please help me with this?
Thanks!
Operating system used: Windows
Best Answer
-
Hi,
Maybe I am wrong or don't understand the problem.
You have nothing more to do than writing to the managed folder, with the pandas library. You just have to change the name of the file, if you want to.
Did you try?
path_of_copy = os.path.join(folder_path, "copy_file_name_with_extension") df.to_csv(path_of_copy)
Hope this helps.
Best
Answers
-
Does the same code work for storing a csv file into a managed folder. I need to do this via Python API endpoint function
-
Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,088 Neuron
When you say via Python API endpoint function what exactly do you mean? API endpoint function means to me an API you have developed and deployed in the Dataiku API node. If you don’t mean that please explain.