python 根据雨滴谱清洗的异常值截断看看这5000多个数据有多少个大于异常值
#!usr/bin/env python # -*- coding:utf-8 -*- """ @author: Suyue @file: hhh.py @time: 2025/04/27 @desc: """ import os def find_files_above_threshold(folder_path, threshold=250): result_files = set() # 使用集合避免重复 # 遍历文件夹中的所有文件 for filename in os.listdir(folder_path): if filename.endswith('.txt'): file_path = os.path.join(folder_path, filename) try: with open(file_path, 'r') as file: lines = file.readlines() # 检查每个数值行 for i in range(1, len(lines), 4): if i < len(lines): try: value = float(lines[i].strip()) if value > threshold: result_files.add(filename) break # 找到一个就足够,跳出循环检查下一个文件 except ValueError: continue except Exception as e: print(f"处理文件 {filename} 时出错: {e}") continue return sorted(result_files) # 返回排序后的列表 # 使用示例 folder_path = 'G:/装备科/论文/03-雨滴谱/雨滴谱数据/物理参量/训练数据(未进行异常值截断)/雨水含量' threshold = 25 above_threshold_files = find_files_above_threshold(folder_path, threshold) print(f"数浓度值大于 {threshold} 的文件共有 {len(above_threshold_files)} 个:") for file in above_threshold_files: print(file)


浙公网安备 33010602011771号