Skip to content

Commit

Permalink
Update process_company_appointments_data.py
Browse files Browse the repository at this point in the history
added buffering = -1 and encoding utf-8 and newline to prevent blank rows in windows
  • Loading branch information
elray authored Sep 17, 2024
1 parent e33a3a7 commit ae61b8e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions process_company_appointments_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit ae61b8e

Please sign in to comment.