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