there is a folder with multiple excel files in it. they are named in a systematic way. Like below
a_b_12_2021043036548.xlsx
a_b_12_ part is fixed
20210430 changes everyday
36548 also change everyday,and there is no rule for the it
I have to read this excel everyday from another script,and save it as a dataframe. how can I do this.
I tried the following lines but failed
datetime_format = datetime.datetime(2021, 4, 30) # I just want to change the date here to read the related excel x=datetime_format.strftime("%Y%m%d") file1 = r'C:/report/FG/a_b_12_' + x + * + '.xlsx' #failed file1 = r'C:/report/FG/a_b_12_' + x + r'[\d\]+' + '.xlsx' #failed
https://stackoverflow.com/questions/67326960/how-to-read-file-name-with-two-variable-in-python April 30, 2021 at 09:12AM
没有评论:
发表评论