|
|
@ -69,8 +69,8 @@ def _cleanup_data_columns(data_frame): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_file(data_file): |
|
|
|
def parse_file(data_file): |
|
|
|
""" parses one data file and adds metadata to result |
|
|
|
"""parses one data file and adds metadata to result |
|
|
|
|
|
|
|
|
|
|
|
will race a ValueError, if metadata could not be extracted |
|
|
|
will race a ValueError, if metadata could not be extracted |
|
|
|
""" |
|
|
|
""" |
|
|
|
measurement_info = _extract_measurement_info(Path(data_file)) |
|
|
|
measurement_info = _extract_measurement_info(Path(data_file)) |
|
|
@ -81,11 +81,22 @@ def parse_file(data_file): |
|
|
|
return _cleanup_data_columns(data_frame) |
|
|
|
return _cleanup_data_columns(data_frame) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _silenced_parse_file(data_file): |
|
|
|
|
|
|
|
"""parses one data file and adds metadata |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
returns data frame or None on ValueError |
|
|
|
|
|
|
|
""" |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
return parse_file(data_file) |
|
|
|
|
|
|
|
except ValueError: |
|
|
|
|
|
|
|
return None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def parse_multiple_files(file_list): |
|
|
|
def parse_multiple_files(file_list): |
|
|
|
""" parses a list of file paths to one combined dataframe """ |
|
|
|
""" parses a list of file paths to one combined dataframe """ |
|
|
|
if not file_list: |
|
|
|
if not file_list: |
|
|
|
raise ValueError("Empty file list provided") |
|
|
|
raise ValueError("Empty file list provided") |
|
|
|
collection = (parse_file(path) for path in file_list) |
|
|
|
collection = (_silenced_parse_file(path) for path in file_list) |
|
|
|
filtered = (frame for frame in collection if frame is not None) |
|
|
|
filtered = (frame for frame in collection if frame is not None) |
|
|
|
data_frame = next(filtered) |
|
|
|
data_frame = next(filtered) |
|
|
|
for next_frame in filtered: |
|
|
|
for next_frame in filtered: |
|
|
|