Oct-28-2022, 03:42 AM
(Oct-27-2022, 08:59 PM)rob101 Wrote: Is this the kind of thing you're looking for?
Thank you. I tried to incorporate the code you supplied and have it process the file
from datetime import datetime f = open("ANCU.qif","r") lines = f.readlines() for line in lines: for index, item in enumerate(line): if index == 0: month = item.lstrip("D") month = "D" + str(f"{int(month):02d}") elif index == 1: day = str(f"{int(item):02d}") else: year = item.rstrip("\n") date = f"{month}/{day}/{year}" print(date) # closing the file f.close()
Output:python3 search_replace_2.py
Traceback (most recent call last):
File "/home/********/VirtualBox VMs/search_replace_2.py", line 12, in <module>
month = "D" + str(f"{int(month):02d}")
ValueError: invalid literal for int() with base 10: '!'
but obviously a string data type problem.