You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because the pointers are limited to 4, I got the ideas to export more than 15 files, and make this python script
Read a whole folder of csv
It will build a common list of all adresses
Take the values of each csv's
Write down a new csv file with ONLY the values that are unique ! (to ensure that it's maybe the right value you are searching for)
Like that, in the final file, I maybe got a few of adresses with the candidates values I'm looking for
Here the script :
import os
import csv
# Path to the directory containing CSV files
directory = r"D:\FINISHED\RALibretro-x64\Saves\Savestats\csv"
# Get the list of CSV files in the directory
csv_files = [file for file in os.listdir(directory) if file.endswith('.csv')]
# Sort files by modification date (most recent first)
csv_files.sort(key=lambda x: os.path.getmtime(os.path.join(directory, x)), reverse=True)
# Use the first file as reference
reference_file = csv_files[0]
# Dictionary to store values for each file
data = {}
# Read data from the reference file
with open(os.path.join(directory, reference_file), 'r') as f:
reader = csv.reader(f)
reference_data = {row[0]: row[1] for row in reader if len(row) > 1}
# Iterate through other files to extract addresses and their corresponding values
for file in csv_files[1:]:
with open(os.path.join(directory, file), 'r') as f:
reader = csv.reader(f)
data[file] = {row[0]: row[1] for row in reader if len(row) > 1}
# Dictionary to store values for each common address
address_values = {}
# Iterate through addresses in the reference file
for address, value in reference_data.items():
# Check if the address exists in all other files
if all(address in file_data for file_data in data.values()):
# Retrieve corresponding values in each file
values = [data[file][address] for file in data.keys()]
# Check if all values are different
if len(set(values)) == len(values):
address_values[address] = values
# Write differing values to a file FINAL.csv
with open('FINAL.csv', 'w', newline='') as final_file:
writer = csv.writer(final_file)
header = ["Address"] + csv_files
writer.writerow(header)
for address, values in address_values.items():
writer.writerow([address] + values)
print("FINAL.csv file has been successfully created.")
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Because the pointers are limited to 4, I got the ideas to export more than 15 files, and make this python script
Like that, in the final file, I maybe got a few of adresses with the candidates values I'm looking for
Here the script :
Beta Was this translation helpful? Give feedback.
All reactions