Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

Save pandas dataframe in folder in Managed folder (XLSX files)

Kevin_dmausy
Level 1
Save pandas dataframe in folder in Managed folder (XLSX files)

Hello expert,

hope you're well. I'm writing to you because I can't fix this code to add my xlsx dataframe in a directory with today's date.

It works fine in csv but I need to store my files in xlsx.

I've tested to_excel but it doesn't work... the file remains at 0bytes.

Can you help me? Thanks a lot!

0 Kudos
3 Replies
Turribeach

Hi, please copy/paste your code in a code block (the </> icon in the message toolbar). 

0 Kudos
Kevin_dmausy
Level 1
Author
import dataiku
import pandas as pd, numpy as np
from dataiku import pandasutils as pdu


from datetime import datetime
todays_date = datetime.today().strftime('%Y-%m-%d')

# Replace dataset anme

Chroniques_2030 = dataiku.Dataset("Chroniques_2030")
Chroniques_2030_df = Chroniques_2030.get_dataframe()

#replace folder_id 
managed_folder_id = "k7dA2Chq"

# Write recipe outputs

sub_path = str(todays_date) + '/'
output_folder = dataiku.Folder(managed_folder_id)
output_folder.upload_stream(sub_path + "Chroniques_2030.csv", Chroniques_2030_df.to_csv(index=False).encode("utf-8"))
0 Kudos
Kevin_dmausy
Level 1
Author

Thank you very much for your reply. Here's the code I use.

0 Kudos