I have written the code for automation of creating file with date and time format. So, the file output would be
Product_Name-date
From this code:
filename = datetime.now().strftime('Product_Name-%Y-%m-%d-%H-%M.csv')
with open(filename, "w+") as f_output:
csv_output = csv.writer(f_output)
csv_output.writerow(["Name", "Price"])
for d in datas: csv_output.writerow(d)
However, I want to ask for input from user to manually name each file. To become:
UserInputProduct_Name-date
I've read the tutorial from W3School, but I can't implement it correctly.
filename = input("Input the Filename: ")
f_extns = filename.split(".")
print ("The extension of the file is : " + repr(f_extns[-1]))
How do I do that?