Advertisement
elena1234

save excel file with current date and sheets in Python

Dec 10th, 2022 (edited)
1,106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | Source Code | 0 0
  1. import pandas as pd
  2. from datetime import datetime
  3.  
  4. currentDay = datetime.now().day
  5. currentMonth = datetime.now().month
  6. currentYear = datetime.now().year
  7. e ='%s.%s.%s'%(currentDay,currentMonth,currentYear)
  8. file_name = 'auto.bg'
  9. writer = pd.ExcelWriter(f'{file_name}{e}.xlsx', engine='openpyxl')
  10. df_diesel.to_excel(writer, sheet_name='Diesel engines')
  11. df_gasoline.to_excel(writer, sheet_name='Gasoline engines')
  12. df_electric.to_excel(writer, sheet_name='Electric engines')
  13. df_hybrid.to_excel(writer, sheet_name='Hybrid engines')
  14. writer.save()
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement