Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Saving pandas excel dataframe with dynamic filename

I am trying to save a dataframe to Excel and unfortunately I am not getting around the Syntax. I want to save the file to a path and Name it by today date.

df.to_excel(r'\\folderA\folderB\Dokumente\'',today.strftime("%d%m%Y")+'delmedf.xlsx')

Am I doing something wrong with the quote signs?

like image 235
Markus W Avatar asked Dec 22 '25 03:12

Markus W


1 Answers

I think you can try add () to today and + before:

import datetime as dt

print dt.datetime.today().strftime("%d%m%Y")
25022016

df.to_excel(r'\\folderA\folderB\Dokumente\\' + dt.datetime.today().strftime("%d%m%Y")+'delmedf.xlsx')
like image 90
jezrael Avatar answered Dec 23 '25 18:12

jezrael



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!