1- # Copyright (C) 2020-2024 Asitha Senanayake
1+ # Copyright (C) 2020-2025 Asitha Senanayake
22#
33# This file is part of python_ags4.
44#
@@ -431,7 +431,8 @@ def excel_to_AGS4(input_file, output_file, format_numeric_columns=True, dictiona
431431 from pandas import read_excel
432432
433433 # Read data from Excel file in to a dictionary of dataframes
434- tables = read_excel (input_file , sheet_name = None , engine = 'openpyxl' )
434+ tables = read_excel (input_file , sheet_name = None , engine = 'openpyxl' ,
435+ keep_default_na = False , na_values = '' )
435436
436437 # Not all worksheets in the spreadsheet may contain valid AGS4 tables, therefore
437438 # initiate variable to keep track of worksheets to export
@@ -688,8 +689,7 @@ def _format_SF(value, TYPE):
688689 return f"{ value :.{i }f} "
689690
690691
691- def check_file (filepath_or_buffer , standard_AGS4_dictionary = None , rename_duplicate_headers = True , encoding = 'utf-8' ,
692- print_output = True ):
692+ def check_file (filepath_or_buffer , standard_AGS4_dictionary = None , rename_duplicate_headers = True , encoding = 'utf-8' ):
693693 """Validate AGS4 file against AGS4 rules.
694694
695695 Parameters
@@ -706,8 +706,6 @@ def check_file(filepath_or_buffer, standard_AGS4_dictionary=None, rename_duplica
706706 to duplicates to make them unique.
707707 encoding : str, default='utf-8'
708708 Encoding of text file.
709- print_output : bool, default=True
710- If True, then print output to the console and the logger, otherwise do not.
711709
712710 Returns
713711 -------
@@ -720,8 +718,6 @@ def check_file(filepath_or_buffer, standard_AGS4_dictionary=None, rename_duplica
720718
721719 ags_errors = {}
722720
723- logger .info (f'Opening file... { filepath_or_buffer } ' )
724-
725721 # Line checks
726722 if _is_file_like (filepath_or_buffer ):
727723 f = filepath_or_buffer
@@ -757,8 +753,6 @@ def check_file(filepath_or_buffer, standard_AGS4_dictionary=None, rename_duplica
757753 headings = []
758754
759755 logger .info ('Checking lines...' )
760- if print_output :
761- logger .info ('Checking lines...' )
762756
763757 for i , line in enumerate (f , start = 1 ):
764758
@@ -955,21 +949,23 @@ def write_error_report(ags_errors, output_file, show_warnings=False, show_fyi=Fa
955949 # Summary of errors log
956950 if error_count == 0 :
957951 f .write ('All checks passed!\r \n ' )
958-
959- if warnings_count + fyi_count > 0 :
960- f .write (f'{ warnings_count } warning(s) and { fyi_count } FYI message(s) returned.\r \n ' )
961- f .write ('\r \n ' )
952+ f .write ('\r \n ' )
962953
963954 elif ('AGS Format Rule 3' in ags_errors ) and ('AGS3' in ags_errors ['AGS Format Rule 3' ][0 ]['desc' ]):
964955 f .write ('Checking aborted as AGS3 files are not supported!\r \n ' )
965956 f .write ('\r \n ' )
966957
967958 else :
968959 f .write (f'{ error_count } error(s) found in file!\r \n ' )
960+ f .write ('\r \n ' )
969961
970- if warnings_count + fyi_count > 0 :
971- f .write (f'{ warnings_count } warning(s) and { fyi_count } FYI message(s) returned.\r \n ' )
962+ # Write summary of warnings and FYI messages
963+ if show_warnings :
964+ f .write (f'{ warnings_count } warning(s) returned.\r \n ' )
965+ f .write ('\r \n ' )
972966
967+ if show_fyi :
968+ f .write (f'{ fyi_count } FYI message(s) returned.\r \n ' )
973969 f .write ('\r \n ' )
974970
975971 # Write 'General' error messages first if present
0 commit comments