1010dir_path = os .path .dirname (os .path .realpath (__file__ ))
1111
1212
13- def get_input_output_folders () -> Tuple [str , str ]:
13+ def get_arguments () -> Tuple [str , str , int ]:
1414 """
1515 Get the input and output folders from the command line
1616 :return: input_folder, output_folder
1717 """
1818 parser = argparse .ArgumentParser (description = 'Get the input and output folder' )
1919 parser .add_argument ('-i' , "--input" , dest = "input_folder" , type = str , help = 'The input folder' , required = True )
2020 parser .add_argument ('-o' , "--output" , dest = "output_folder" , type = str , help = 'The output folder' , required = True )
21+ parser .add_argument ('-thl' , "--temp_header_lines" , dest = "num_of_temp_header_lines" , type = int , help = 'The number of header lines to strip from temp files' , required = False , default = 1 )
2122 args = parser .parse_args ()
22- return os .path .join (dir_path , args .input_folder ), os .path .join (dir_path , args .output_folder )
23+ return os .path .join (dir_path , args .input_folder ), os .path .join (dir_path , args .output_folder ), args . num_of_temp_header_lines
2324
2425
2526class FileConverter :
@@ -109,7 +110,7 @@ def convert_file(root, original_file_name) -> None:
109110 convert_curve_files .convert (original_file_name , output_folder , root )
110111 # If the file is in .dat format
111112 if original_file_name .endswith (FileTypes .ORIGINAL_DAT_FILE_EXTENSION ):
112- convert_temp_calib_files .convert (original_file_name , output_folder , root )
113+ convert_temp_calib_files .convert (original_file_name , output_folder , root , num_of_temp_header_lines )
113114
114115 def convert_all_files (self ) -> None :
115116 """
@@ -119,15 +120,11 @@ def convert_all_files(self) -> None:
119120 for root , _ , files in os .walk (self .input_dir ):
120121 for original_file_name in files :
121122 self .convert_file (root , original_file_name )
122- # We've found the file to convert so don't need to look at any other in the directory
123- break
124- else :
125- print (f"Could not find file to convert in { root } " )
126123
127124
128125if __name__ == "__main__" :
129126 # Get the input and output folders from the command line
130- input_folder , output_folder = get_input_output_folders ()
127+ input_folder , output_folder , num_of_temp_header_lines = get_arguments ()
131128 # Create Instance of FileConverter
132129 file_converter = FileConverter (input_folder , output_folder )
133130 # Check input folder exists
0 commit comments