Markus W
Markus W

Reputation: 1493

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?

Upvotes: 3

Views: 8619

Answers (1)

jezrael
jezrael

Reputation: 862641

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')

Upvotes: 4

Related Questions