Read data from txt with 1 returned values. Args: path (str): path to the txt file. pattern (str): re (regular expression) pattern.
(path, pattern)
| 46 | |
| 47 | |
| 48 | def read_data_from_txt_1v(path, pattern): |
| 49 | """Read data from txt with 1 returned values. |
| 50 | |
| 51 | Args: |
| 52 | path (str): path to the txt file. |
| 53 | pattern (str): re (regular expression) pattern. |
| 54 | """ |
| 55 | with open(path) as f: |
| 56 | lines = f.readlines() |
| 57 | lines = [line.strip() for line in lines] |
| 58 | data = [] |
| 59 | |
| 60 | pattern = re.compile(pattern) |
| 61 | for line in lines: |
| 62 | match = pattern.match(line) |
| 63 | if match: |
| 64 | data.append(float(match.group(1))) |
| 65 | return data |
| 66 | |
| 67 | |
| 68 | def smooth_data(values, smooth_weight): |
nothing calls this directly
no outgoing calls
no test coverage detected