[modify] skip when data is invalid
This commit is contained in:
		| @@ -169,14 +169,14 @@ def single_file_process(data_file, wb_result, count, av, rr, axis, vel, trq, w2t | ||||
|     result_sheet_name = find_result_sheet_name(conditions, count) | ||||
|     ws_result = wb_result[result_sheet_name] | ||||
|  | ||||
|     row_max, row_start = find_row_start(data_file, df, conditions, av, rr, axis, vel, w2t, rpm) | ||||
|     row_max, row_start, flag = find_row_start(data_file, df, conditions, av, rr, axis, vel, w2t, rpm) | ||||
|  | ||||
|     copy_data_to_result(df, ws_result, row_max, row_start, vel, trq, rpm) | ||||
|     copy_data_to_result(flag, df, ws_result, row_max, row_start, vel, trq, rpm) | ||||
|     ws_result["C2"] = int(2) | ||||
|     ws_result["G2"] = int(10+4) | ||||
|  | ||||
|  | ||||
| def copy_data_to_result(df, ws_result, row_max, row_start, vel, trq, rpm): | ||||
| def copy_data_to_result(flag, df, ws_result, row_max, row_start, vel, trq, rpm): | ||||
|     # 功能:将数据文件中有效数据拷贝至结果文件对应的 sheet | ||||
|     # 参数:如上 | ||||
|     # 返回值:- | ||||
| @@ -185,20 +185,23 @@ def copy_data_to_result(df, ws_result, row_max, row_start, vel, trq, rpm): | ||||
|         for cell in row: | ||||
|             cell.value = None | ||||
|  | ||||
|     # 将合适的数据复制到结果文件 | ||||
|     row_max = row_start + 399 if row_max-row_start > 400 else row_max | ||||
|     rc = 1 if rpm == 1 else 1000 | ||||
|     if flag == 1: | ||||
|         # 将合适的数据复制到结果文件 | ||||
|         row_max = row_start + 399 if row_max-row_start > 400 else row_max | ||||
|         rc = 1 if rpm == 1 else 1000 | ||||
|  | ||||
|     data = [] | ||||
|     for i in range(row_start, row_max+1): | ||||
|         data.append(df.iloc[i, vel-1] * rpm) | ||||
|         data.append(df.iloc[i, trq-1] * rc) | ||||
|         data = [] | ||||
|         for i in range(row_start, row_max+1): | ||||
|             data.append(df.iloc[i, vel-1] * rpm) | ||||
|             data.append(df.iloc[i, trq-1] * rc) | ||||
|  | ||||
|     i = 0 | ||||
|     for row in ws_result.iter_rows(min_row=2, min_col=1, max_row=row_max - row_start + 2, max_col=2): | ||||
|         for cell in row: | ||||
|             cell.value = data[i] | ||||
|             i = i + 1 | ||||
|         i = 0 | ||||
|         for row in ws_result.iter_rows(min_row=2, min_col=1, max_row=row_max - row_start + 2, max_col=2): | ||||
|             for cell in row: | ||||
|                 cell.value = data[i] | ||||
|                 i = i + 1 | ||||
|     else: | ||||
|         pass | ||||
|  | ||||
|  | ||||
| def find_result_sheet_name(conditions, count): | ||||
| @@ -235,14 +238,16 @@ def find_row_start(data_file, df, conditions, av, rr, axis, vel, w2t, rpm): | ||||
|  | ||||
|         if abs(speed_avg-speed_max) < threshold: | ||||
|             row_start = row_start - 10 | ||||
|             flag = 1 | ||||
|             break | ||||
|         else: | ||||
|             row_start -= step | ||||
|     else: | ||||
|         msg = f"可能是{data_file}这个文件数据采集有问题,比如未采集理论速度值,也有可能是程序步长设定问题,请检查......" | ||||
|         w2t(msg) | ||||
|         flag = 0 | ||||
|  | ||||
|     return row_max, row_start | ||||
|     return row_max, row_start, flag | ||||
|  | ||||
|  | ||||
| def get_threshold_step(excel_file, axis): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user