From ae61b8e7b73055359ebc30cfb01b66eeb570e125 Mon Sep 17 00:00:00 2001 From: Eliot Rayner Date: Tue, 17 Sep 2024 12:03:02 +0100 Subject: [PATCH] Update process_company_appointments_data.py added buffering = -1 and encoding utf-8 and newline to prevent blank rows in windows --- process_company_appointments_data.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/process_company_appointments_data.py b/process_company_appointments_data.py index aaccc95..d1c49f8 100644 --- a/process_company_appointments_data.py +++ b/process_company_appointments_data.py @@ -77,7 +77,8 @@ def process_person_row(row, output_writer): def init_company_output_file(filename): - output_companies_file = open(filename, 'w') + # 11SEP2024 : added buffering = -1 and encoding utf-8 and newline to prevent blank rows in windows + output_companies_file = open(filename, 'w', -1, 'utf-8', newline='') companies_writer = csv.writer(output_companies_file, delimiter=",") companies_writer.writerow([ "Company Number", "Company Status", "Number of Officers", @@ -87,7 +88,8 @@ def init_company_output_file(filename): def init_person_output_file(filename): - output_persons_file = open(filename, 'w') + # 11SEP2024 : added buffering = -1 and encoding utf-8 and newline to prevent blank rows in windows + output_persons_file = open(filename, 'w', -1, 'utf-8', newline='') persons_writer = csv.writer(output_persons_file, delimiter=",") persons_writer.writerow([ "Company Number", "App Date Origin", "Appointment Type", @@ -159,7 +161,8 @@ def process_company_appointments_data(input_file, output_folder, sys.exit(1) input_filename = sys.argv[1] output_folder = sys.argv[2] - input_file = open(input_filename, 'r') + # 11SEP2024 : added buffering = -1 and encoding utf-8 + input_file = open(input_filename, 'r', -1, 'utf-8') base_input_name = os.path.basename(input_filename) # Do not include the extension in the base input name base_input_name = os.path.splitext(base_input_name)[0]