Aug-03-2020, 02:25 PM
you greatly modified your code after my post, (as seen by clicking 'view edit history' on original post)
so now it looks like my response was entirely out of context!
it looks like inFile is a file pointer, which had to be opened somewhere (nor shown) within the program
wherever that occurs, you need to to capture the 'stem' of the filename, and modify line 24 to read (I am can't show how to do this as you do not show where file was opened):
example: (assuming stem was created from inFile file name)
so now it looks like my response was entirely out of context!
it looks like inFile is a file pointer, which had to be opened somewhere (nor shown) within the program
wherever that occurs, you need to to capture the 'stem' of the filename, and modify line 24 to read (I am can't show how to do this as you do not show where file was opened):
filename = f"{stem}{datetime.today().strftime('%Y%m%d_%H%M%S')}.txt"
example: (assuming stem was created from inFile file name)
>>> from datetime import datetime >>> stem = 'ziggy' # extract stem from name of inFile >>> filename = f"{stem}{datetime.today().strftime('%Y%m%d_%H%M%S')}.txt" >>> print(filename) ziggy20200803_102219.txt >>>