From 9439a4e2511b6c36ea59944c8034590f6a5967f5 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 4 Apr 2024 10:48:41 +0100 Subject: [PATCH] Update to handle two digit dates in filenames as they are published --- src/parse_docx.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/parse_docx.py b/src/parse_docx.py index 3c154a6..f77c75b 100644 --- a/src/parse_docx.py +++ b/src/parse_docx.py @@ -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)