Answer:
Explanation:
I have written the Python program based on your requirements.
Just give the path of the input file and the path for the output file correctly where you want to place the output file.
In, my code - I have given my computer's path to the input and output file.
You just change the path correctly
My code works perfectly and I have tested the code with your inputs.
It gives the exact output that you need.
I have attached the Output that I got by running the below program.
Code:
month_list={ "january":"1","february":"2", "march":"3","april":"4", "may":"5", "june":"6","july":"7", "august":"8", "september":"9","october":"10", "november":"11", "december":"12"} input_file=open('C:\\Users\\Desktop\\inputDates.txt', 'r') output_file=open('C:\\Users\\Desktop\\parsedDates.txt','w') for each in input_file: if each!="-1": lis=each.split() if len (lis) >=3: month=lis [0] day=lis[1] year=lis [2] if month.lower() in month_list: comma=day[-1] if comma==',': day=day[:len (day)-1] month_number=month_list[month.lower()] ans-month_number+"/"+day+"/"+year output_file.write (ans) output_file.write("\n") output_file.close() input_file.close()
- O X parsedDates - Notepad File Edit Format View Help 3/1/1990 12/13/2003
- X inputDates - Notepad File Edit Format View Help March 1, 1990 April 2 1995 7/15/20 December 13, 2003 -1
cheers i hope this helped !!