Update to handle two digit dates in filenames as they are published

This commit is contained in:
Fred Boniface 2024-04-04 10:48:41 +01:00
parent 38053cf161
commit 9439a4e251
1 changed files with 3 additions and 1 deletions

View File

@ -25,7 +25,9 @@ def extract_tables(file_path):
pis_and_headcode = match_pis_and_headcode(data)
if pis_and_headcode:
pis_and_headcode['source_file'] = file_path
pis_and_headcode['date'] = datetime.strptime(file_path.split('_')[0], "%Y%m%d")
current_year = datetime.now().year
date_string_with_year = f"{current_year}{datetime.strptime(file_path.split[' '][0])}"
pis_and_headcode['date'] = datetime.strptime(date_string_with_year, "%Y%m%d")
pis_info.append(pis_and_headcode)
return(pis_info)