47 lines
1.5 KiB
Python
47 lines
1.5 KiB
Python
import pandas as pd
|
|
|
|
from global_var import global_var_init
|
|
cycle, fs_ecg, fs_ppg, record_name, record_name_csv = global_var_init()
|
|
|
|
|
|
def find_large_values(excel_file, threshold=0.6): # 调整阈值
|
|
# 读取Excel文件中的所有sheet
|
|
df = pd.read_excel(excel_file, sheet_name=None)
|
|
|
|
# 存储结果的列表
|
|
results = []
|
|
|
|
# 遍历每一个sheet
|
|
for sheet_name, data in df.items():
|
|
# 获取每一个单元格的行列位置和数据
|
|
for row_idx in range(data.shape[0]):
|
|
for col_idx in range(data.shape[1]):
|
|
value = data.iat[row_idx, col_idx]
|
|
# 检查是否大于阈值
|
|
if isinstance(value, (int, float)) and value > threshold:
|
|
cell_location = (sheet_name, row_idx + 2, col_idx + 1) # Excel行列从1开始计数
|
|
results.append(cell_location)
|
|
|
|
return results
|
|
|
|
def append_to_file(results, output_file):
|
|
with open(output_file, 'a') as f:
|
|
f.write("")
|
|
for result in results:
|
|
f.write(f'Sheet: {result[0]}, Row: {result[1]}, Column: {result[2]}\n')
|
|
f.write("########################\n")
|
|
|
|
def main():
|
|
|
|
excel_file = f"D://python_study//big_boss//doc//output//{record_name}_output.xlsx" # Excel文件路径
|
|
output_file = f"D://python_study//big_boss//doc//output//processed.txt" # 输出文件路径
|
|
results = find_large_values(excel_file)
|
|
|
|
# 将结果追加到文件
|
|
append_to_file(results, output_file)
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|
|
|