2

Im trying to save the excel file generated in two different folders (output1, output2)

I tried this and didnt worked

writer = pd.ExcelWriter([output1,output2], engine='xlsxwriter')
df1.to_excel(writer, sheet_name='sheeta', index = None)

Thanks

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69
Rexilife
  • 565
  • 1
  • 4
  • 7

1 Answers1

3

You can copy the file using How do I copy a file in Python? after you created it once ... or simply write it twice:

import pandas as pd

output1 = "p.xlsx"
output2 = "q.xlsx"
df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})

for o in [output1,output2]:
    writer = pd.ExcelWriter(o, engine='xlsxwriter')
    df.to_excel(writer, sheet_name='Sheet1')
    writer.save()

Results in 2 files being written, containing the data:

xlxs content

Doku:

Patrick Artner
  • 50,409
  • 9
  • 43
  • 69