Oct-28-2022, 10:17 PM
(Oct-28-2022, 08:58 AM)Larz60+ Wrote: You don't need testit.
try this (as I cannot test):
Thanks, I only had to modify line 5 as it didn't like double quotes within the "F" statement, so ..
import datetime def convert_date(orig): massaged_date = orig.replace("'", "/")[1:] return f"D{datetime.datetime.strftime(datetime.datetime.strptime(massaged_date, '%m/%d/%Y'), '%m/%d/%Y')}" def clean_file(filename): with open(filename,"r") as f: line = f.readline().strip() if line[0] == "D": # this could also read "if line.startswith("D"):" convert_date(line) print(line) else: print(line) clean_file("ANCU.qif")it only read one line, so I added a "for" loop but that didn't work.