text stringlengths 0 96 |
|---|
import os |
import shutil |
base_dir = "/storage/home/winston06/Rongyun/data/35kV/revised_data" |
input_dir = os.path.join(base_dir, "input") |
output_dir = os.path.join(base_dir, "output") |
target_dir = "/storage/home/winston06/Rongyun/data/35kV/revise_data_v2" |
target_input_dir = os.path.join(target_dir, "input") |
target_output_dir = os.path.join(target_dir, "output") |
os.makedirs(target_input_dir, exist_ok=True) |
os.makedirs(target_output_dir, exist_ok=True) |
count_all_greater = 0 |
total_files = 0 |
files_all_greater = [] |
for subdir in os.listdir(output_dir): |
subdir_path = os.path.join(output_dir, subdir) |
if os.path.isdir(subdir_path): |
for filename in os.listdir(subdir_path): |
if filename.endswith('.txt'): |
filepath = os.path.join(subdir_path, filename) |
total_files += 1 |
all_greater = True |
try: |
with open(filepath, 'r') as f: |
for line in f: |
line = line.strip() |
if line: |
value = float(line) |
if value <= 273: |
all_greater = False |
break |
if all_greater: |
count_all_greater += 1 |
files_all_greater.append(subdir) |
except Exception as e: |
print(f"Error reading {filepath}: {e}") |
print(f"总共有 {total_files} 个txt文件") |
print(f"所有值都大于273的文件数量: {count_all_greater}") |
print(f"\n这些文件所在的子目录编号: {sorted([int(x) for x in files_all_greater])}") |
copied_count = 0 |
for idx in files_all_greater: |
src_input = os.path.join(input_dir, idx) |
src_output = os.path.join(output_dir, idx) |
dst_input = os.path.join(target_input_dir, idx) |
dst_output = os.path.join(target_output_dir, idx) |
if os.path.exists(src_input) and os.path.exists(src_output): |
if os.path.exists(dst_input): |
shutil.rmtree(dst_input) |
if os.path.exists(dst_output): |
shutil.rmtree(dst_output) |
shutil.copytree(src_input, dst_input) |
shutil.copytree(src_output, dst_output) |
copied_count += 1 |
else: |
print(f"警告: idx={idx} 的input或output目录不存在") |
print(f"\n已复制 {copied_count} 组数据到 {target_dir}") |
1,-1.977484843E-08,-5.074999928E-01,-2.325000018E-01, 3.139786987E+02 |
2, 3.968637437E-03,-5.074517727E-01,-2.325000018E-01, 3.139872131E+02 |
3,-3.981671762E-03,-5.074514151E-01,-2.325000018E-01, 3.139610901E+02 |
4, 7.948031649E-03,-5.073093176E-01,-2.325000018E-01, 3.139949951E+02 |
5,-7.961059920E-03,-5.073086619E-01,-2.325000018E-01, 3.139321899E+02 |
6, 1.192293502E-02,-5.070726275E-01,-2.325000018E-01, 3.140066528E+02 |
7,-1.193595119E-02,-5.070716739E-01,-2.325000018E-01, 3.139169006E+02 |
8, 1.589110866E-02,-5.067417622E-01,-2.325000018E-01, 3.140206299E+02 |
9,-1.590410434E-02,-5.067405105E-01,-2.325000018E-01, 3.139490662E+02 |
10, 1.985031180E-02,-5.063167810E-01,-2.325000018E-01, 3.140380249E+02 |
11,-1.986327954E-02,-5.063152313E-01,-2.325000018E-01, 3.140015564E+02 |
12, 2.379830368E-02,-5.057979226E-01,-2.325000018E-01, 3.140583191E+02 |
13,-2.381123602E-02,-5.057960749E-01,-2.325000018E-01, 3.140321960E+02 |
14, 2.773907594E-02,-5.051842928E-01,-2.325000018E-01, 3.140799866E+02 |
15,-2.774573863E-02,-5.051832199E-01,-2.325000018E-01, 3.140447083E+02 |
16,-1.140739489E-02,-5.049805045E-01,-2.325000018E-01, 3.140026550E+02 |
17,-3.167253360E-02,-5.044754148E-01,-2.325000018E-01, 3.140636902E+02 |
18, 3.167740256E-02,-5.044745207E-01,-2.325000018E-01, 3.141027222E+02 |
19,-8.533035405E-03,-5.042647123E-01,-2.325000018E-01, 3.140617676E+02 |
20, 3.558549657E-02,-5.036734343E-01,-2.325000018E-01, 3.141244507E+02 |
21,-3.559409454E-02,-5.036715865E-01,-2.325000018E-01, 3.140963135E+02 |
22,-4.644464701E-03,-5.036605000E-01,-2.325000018E-01, 3.141155396E+02 |
23,-3.713926126E-04,-5.035465360E-01,-2.325000018E-01, 3.141275635E+02 |
24, 3.775263904E-03,-5.034595132E-01,-2.325000018E-01, 3.141319275E+02 |
25, 7.839708589E-03,-5.033099055E-01,-2.325000018E-01, 3.141355591E+02 |
26,-1.348456927E-02,-5.032379031E-01,-2.325000018E-01, 3.141103516E+02 |
27, 1.185367443E-02,-5.030744672E-01,-2.325000018E-01, 3.141395264E+02 |
28, 3.946619108E-02,-5.027811527E-01,-2.325000018E-01, 3.141412048E+02 |
29,-3.947670385E-02,-5.027786493E-01,-2.325000018E-01, 3.141380005E+02 |
30, 1.583976299E-02,-5.027441978E-01,-2.325000018E-01, 3.141439819E+02 |
31, 1.980605721E-02,-5.023157001E-01,-2.325000018E-01, 3.141490479E+02 |
32, 4.332457110E-02,-5.017969012E-01,-2.325000018E-01, 3.141520081E+02 |
33,-4.333502427E-02,-5.017940998E-01,-2.325000018E-01, 3.141802673E+02 |
End of preview. Expand
in Data Studio
No dataset card yet
- Downloads last month
- 12