Export multiple datasets into one single excel file with multiple sheets

Solved!
FrancescoRusso
Level 1
Export multiple datasets into one single excel file with multiple sheets
Hi All,

I am trying to export different processed datasets ( for example dataset1 and dataset2) into one single excel file with multiple work sheets ( sheet 1 containing dataset1 and sheet 2 containing dataset2). Is this possible?
0 Kudos
1 Solution
AshleyW
Dataiker

Hi @FrancescoRusso ,

In addition to what has been suggested, you may also consider the Multisheet Excel export plugin which lets you take several different datasets and export them onto different tabs of a single Excel file.

Cheers,

Ashley W.

 

 

 

View solution in original post

0 Kudos
5 Replies
Alex_Combessie
Dataiker Alumni

Hi,



This is quite easy to do with a bit of Python code: see example on http://xlsxwriter.readthedocs.io/example_pandas_multiple.html.



The equivalent also exists in R code: 



https://statmethods.wordpress.com/2014/06/19/quickly-export-multiple-r-objects-to-an-excel-workbook/



Cheers,



Alex

0 Kudos
FrancescoRusso
Level 1
Author
Hi Alex,

Thanks for your answer. However, I cannot import the module 'xlsxwriter' on python environment on Dataiku.

Moreover, I have the issue of saving the merged excel file in an existing folder on dataiku. Would you be so kind to share an example?
0 Kudos
Alex_Combessie
Dataiker Alumni
Here is how to install a package on the Dataiku python environment: https://www.dataiku.com/learn/guide/code/python/install-python-packages.html

Reading and writing from/to "managed_folders" is documented here: https://doc.dataiku.com/dss/latest/connecting/managed_folders.html#usage-in-python
0 Kudos
UserBird
Dataiker

Hi Francesco,



You can write to a folder with a python script. The file below shows how to write in the test_writeExcel.



test_writeExcel = dataiku.Folder("RaZzKNKs")

test_writeExcel_info = test_writeExcel.get_info()



name = 'test.xlsx'



df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})



path = os.path.join(test_writeExcel_info['path'], name)



writer = pd.ExcelWriter(path)



df.to_excel(writer, sheet_name='Sheet1', encoding='utf-8')



writer.save()



 



 

AshleyW
Dataiker

Hi @FrancescoRusso ,

In addition to what has been suggested, you may also consider the Multisheet Excel export plugin which lets you take several different datasets and export them onto different tabs of a single Excel file.

Cheers,

Ashley W.

 

 

 

0 Kudos

Labels

?
Labels (2)
A banner prompting to get Dataiku