How to save file in subfolder when I using dataiku.Folder("xxxxxx")?

dataicool
Level 2
How to save file in subfolder when I using dataiku.Folder("xxxxxx")?

python code, I save dataframe as csv๏ผš

#df is pd.DataFrame
csv_name = "data.csv"

handle = dataiku.Folder("xxxxxxx")
    with handle.get_writer(csv_name) as w:
    w.write(df.to_csv().encode('utf-8'))

 

Now I want to save csv in subfolder,

for example save_path =  dataiku.Folder("xxxxxxx")/subfolder1/data.csv

how to change my code?

thanks 


Operating system used: windows

0 Kudos
2 Replies
FlorentD
Developer Advocate

Hi @dataicool

you can use:

csv_name = "/subfolder1/data.csv"
with handle.get_writer(csv_name) as w:
    w.write(df.to_csv().encode('utf-8'))

Hope this helps,

0 Kudos
dataicool
Level 2
Author

code works๐Ÿ‘๐Ÿ‘๐Ÿ‘, thanks a lot, 

0 Kudos