Hello. I am having a hard time exporting table to excel while time or date stamping the .xls file. Right now my py scrips runs through its steps and exports an excel file. I'd like the excel file name to by appended with the current date (or time).
I just can't seem to append the variable to the output filename in the following line. arcpy.TableToExcel_conversion(in_table, out_xls)
.
Thanks.
To show you more or less how you can do this:
import os import datetime currentdate = datetime.date.today() print currentdate out_name = "C:\\Users\\xander_mavrides\\Desktop\\DAILY ESO_Moratorium_List.xls" xls_path, xls_fullname = os.path.split(out_name) print "xls_path : {0}".format(xls_path) print "xls_fullname : {0}".format(xls_fullname) xls_name, xls_ext = os.path.splitext(xls_fullname) print "xls_name : {0}".format(xls_name) print "xls_ext : {0}".format(xls_ext) new_xls_fullname = "{0}_{1}{2}".format(xls_name, currentdate, xls_ext) print "new_xls_fullname : {0}".format(new_xls_fullname) new_xls_filepath = os.path.join(xls_path, new_xls_fullname) print "new_xls_filepath : {0}".format(new_xls_filepath)
returns:
2015-01-23
xls_path : C:\Users\xander_mavrides\Desktop
xls_fullname : DAILY ESO_Moratorium_List.xls
xls_name : DAILY ESO_Moratorium_List
xls_ext : .xls
new_xls_fullname : DAILY ESO_Moratorium_List_2015-01-23.xls
new_xls_filepath : C:\Users\xander_mavrides\Desktop\DAILY ESO_Moratorium_List_2015-01-23.xls