| 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.") | |