Submit your innovative use case or inspiring success story to the 2023 Dataiku Frontrunner Awards! LET'S GO

How to save a dataframe as a csv in a managed folder?

Solved!
Usersyed
Level 3
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

0 Kudos
1 Solution
FlorentD
Developer Advocate

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

View solution in original post

0 Kudos
1 Reply
FlorentD
Developer Advocate

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

0 Kudos