File size: 882 Bytes
ca165c7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import os
import pandas as pd

# Initialize an empty list to store loopnum dataframes
loopnum_dataframes = []

# Iterate through loopnum1 to loopnum6
for i in range(1, 11):
    loopnum_file = f'loopnum{i}.csv'
    
    # Check if the loopnum file exists before trying to read it
    if not os.path.exists(loopnum_file):
        print(f"Warning: {loopnum_file} not found. Skipping.")
    else:
        loopnum_data = pd.read_csv(loopnum_file, header=None)
        loopnum_dataframes.append(loopnum_data)

# Check if any valid loopnum files were found
if loopnum_dataframes:
    # Concatenate the loopnum dataframes into one dataframe
    result_matrix2 = pd.concat(loopnum_dataframes, ignore_index=True)

    # Save the result_matrix2 to a CSV file without a header
    result_matrix2.to_csv('matrix2.csv', header=False, index=False)
else:
    print("No valid loopnum files found.")