diff --git a/sensospot_data/__init__.py b/sensospot_data/__init__.py index 1591c36..470158b 100644 --- a/sensospot_data/__init__.py +++ b/sensospot_data/__init__.py @@ -87,6 +87,14 @@ def _parse_recursive(source, outfile, quiet): child_outfile = DEFAULT_OUTPUT_FILENAME source_path = Path(source) folders = (i for i in source_path.iterdir() if i.is_dir()) - collection = (_parse_one_folder(f, child_outfile, quiet) for f in folders) - collected_data = pandas.concat(collection, ignore_index=True).reset_index() - _output(collected_data, source_path, outfile) + non_hidden = (i for i in folders if not i.name.startswith(".")) + collection = ( + _parse_one_folder(f, child_outfile, quiet) for f in non_hidden + ) + try: + collected_data = pandas.concat( + collection, ignore_index=True + ).reset_index() + _output(collected_data, source_path, outfile) + except ValueError as e: + print(str(e)) diff --git a/sensospot_data/parser.py b/sensospot_data/parser.py index 4137059..6e5fa73 100755 --- a/sensospot_data/parser.py +++ b/sensospot_data/parser.py @@ -140,10 +140,21 @@ def _sanity_check(data_frame): def parse_folder(folder, quiet=False): - """parses all csv files in a folder to one large dataframe""" + """parses all csv files in a folder to one large dataframe + + Will raise an ValueError, if no sensospot data could be found in + the folder + + folder: path of folder containing data files + quiet: skip sanity check, defaults to False + returns: pandas dataframe with parsed data + """ folder_path = Path(folder) file_list = list_csv_files(folder_path) - data_frame = parse_multiple_files(file_list) + try: + data_frame = parse_multiple_files(file_list) + except ValueError: + raise ValueError(f"No sensospot data found in folder '{folder}'") data_frame = add_optional_measurement_parameters(data_frame, folder_path) if quiet: return data_frame