@@ -30,7 +30,7 @@ def __init__(self, input_path, remove_timing_outliers=True):
3030
3131 Parameters
3232 ----------
33- input_path : string
33+ input_path : string or path-like
3434 Path to measurement csv file
3535 remove_timing_outliers : bool
3636 Flag for whether to remove measures that are too close or
@@ -157,7 +157,7 @@ def __init__(self, input_path):
157157
158158 Parameters
159159 ----------
160- input_path : string
160+ input_path : string or path-like
161161 Path to measurement csv file
162162 """
163163 super ().__init__ (csv_path = input_path )
@@ -255,7 +255,7 @@ def __init__(self, input_path):
255255
256256 Parameters
257257 ----------
258- input_path : string
258+ input_path : string or path-like
259259 Path to measurement csv file
260260 """
261261
@@ -369,7 +369,7 @@ def preprocess(self, input_path):
369369
370370 Parameters
371371 ----------
372- input_path : string
372+ input_path : string or path-like
373373 File location of data file to read.
374374
375375 Returns
@@ -380,6 +380,12 @@ def preprocess(self, input_path):
380380 Dataframe that contains the gyro measurements from the log.
381381
382382 """
383+
384+ if not isinstance (input_path , (str , os .PathLike )):
385+ raise TypeError ("input_path must be string or path-like" )
386+ if not os .path .exists (input_path ):
387+ raise FileNotFoundError ("file not found" )
388+
383389 with open (input_path , encoding = "utf8" ) as csvfile :
384390 reader = csv .reader (csvfile )
385391 for row in reader :
@@ -435,7 +441,7 @@ def preprocess(self, input_path):
435441
436442 Parameters
437443 ----------
438- input_path : string
444+ input_path : string or path-like
439445 File location of data file to read.
440446
441447 Returns
@@ -444,6 +450,12 @@ def preprocess(self, input_path):
444450 Dataframe that contains the location fixes from the log.
445451
446452 """
453+
454+ if not isinstance (input_path , (str , os .PathLike )):
455+ raise TypeError ("input_path must be string or path-like" )
456+ if not os .path .exists (input_path ):
457+ raise FileNotFoundError ("file not found" )
458+
447459 with open (input_path , encoding = "utf8" ) as csvfile :
448460 reader = csv .reader (csvfile )
449461 for row in reader :
@@ -463,7 +475,7 @@ def make_csv(input_path, output_directory, field, show_path=False):
463475
464476 Parameters
465477 ----------
466- input_path : string
478+ input_path : string or path-like
467479 File location of data file to read.
468480 output_directory : string
469481 Directory where new csv file should be created
@@ -488,6 +500,12 @@ def make_csv(input_path, output_directory, field, show_path=False):
488500 output_path = os .path .join (output_directory , field + ".csv" )
489501 with open (output_path , 'w' , encoding = "utf8" ) as out_csv :
490502 writer = csv .writer (out_csv )
503+
504+ if not isinstance (input_path , (str , os .PathLike )):
505+ raise TypeError ("input_path must be string or path-like" )
506+ if not os .path .exists (input_path ):
507+ raise FileNotFoundError ("file not found" )
508+
491509 with open (input_path , 'r' , encoding = "utf8" ) as in_txt :
492510 for line in in_txt :
493511 # Comments in the log file
0 commit comments