I want to add a timestamp to my file name for the ease to recognize the latest file.
for this, I tried the following code:-
csv_file = pd.read_csv('C:/Users/anujp/Desktop/sort/Entity_Resolution_Project/data/csv_files/all_web_final_ds.csv',usecols=['page_title'])
page_tile_list=list(csv_file['page_title'])
filename1 = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
timestamp_string = str(filename1)
with open('C:/Users/anujp/Desktop/sort/Entity_Resolution_Project/data/text_files/all_ds_pagetitles.txt' + timestamp_string,'w',encoding='utf-8',) as f:
for item in page_tile_list:
f.write('%s\n'%item)
unfortunately, I am getting an error as
OSError: [Errno 22] Invalid argument: 'C:/Users/anujp/Desktop/sort/Entity_Resolution_Project/data/text_files/all_ds_pagetitles.txt2020-03-19 16:49:21'
Please help me with this.