How add timestamp to excel file using python script?

228 views
Skip to first unread message

ramesh.p...@ramyamlab.com

unread,
Mar 14, 2015, 10:04:00 PM3/14/15
to python...@googlegroups.com
Hi,

I want to add timestamp to excel file using python. Can you please tell me below works or not?
curtme = datetime.datetime.strftime(datetime.datetime.now(), '%Y-%m-%d %H:%M:%S')
book.save(('/home/stp/Desktop/STPAutomationFramework/ExportFiles/STPTestResults.xls')+curtme)

Regards,
Ramesh

John Machin

unread,
Mar 14, 2015, 10:53:12 PM3/14/15
to python...@googlegroups.com
It won't work, as you could have determined by experimentation faster than posting.

Effectively, you are passing "constant path.xls" + curtme.
You need something like "constant path" + "separator char" + curtme + ".xls" 

Separator char is in case you think this is not pretty enough
/home/stp/Desktop/STPAutomationFramework/ExportFiles/STPTestResults2015-03-15 13:33:16.xls'
and prefer something like
/home/stp/Desktop/STPAutomationFramework/ExportFiles/STPTestResults-2015-03-15 13:33:16.xls'

Note that curtime evaluates to something like '2015-03-15 13:33:16' and as you have avoided spaces everywhere else in the path, you may want to put something, e.g. "T" between the date and the time.

BTW your problem all about generating paths on the fly, nothing to do with excel.
BTW2 If you want your app to be portable: Windows won't like the colon (":"), and a whole lot of other characters.

HTH,
John
 

Celso Vicente Mercado

unread,
Mar 16, 2015, 4:51:05 PM3/16/15
to python...@googlegroups.com
convert the variable to String
str(curtme)
and you can use on every place on your achive. ñ.ñ


--
You received this message because you are subscribed to the Google Groups "python-excel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-excel...@googlegroups.com.
To post to this group, send email to python...@googlegroups.com.
Visit this group at http://groups.google.com/group/python-excel.
For more options, visit https://groups.google.com/d/optout.



--
ñ.ñ Yeah !!
Reply all
Reply to author
Forward
0 new messages