This commit is contained in:
2023-01-04 17:12:09 -03:00
parent b48012bfa3
commit 5d7d125521

View File

@ -1,37 +1,31 @@
#This diffs two csv files, It's useful for mods and stuff.
#... I haven't actually tried this yet, it might work, it might not. # This diffs two csv files, It's useful for mods and stuff.
# If it doesn't. Call my number (It's hidden in your ear!). # Nevermind, I suggest deleting all the files in the scripts folder when generating the dialogue file instead.
# But I'm sure someone might find a use for this
def main():
# Open the input files
file1 = open("file1.csv", "r", encoding="utf8")
file2 = open("file2.csv", "r", encoding="utf8")
# Read the contents of the input files into variables # Open the input files
text1 = file1.readlines() file1 = open("file1.csv", "r", encoding="utf8")
text2 = file2.readlines() file2 = open("file2.csv", "r", encoding="utf8")
# Close the input files # Read the contents of the input files into variables
file1.close() text1 = file1.readlines()
file2.close() text2 = file2.readlines()
# Create a set of the lines in each file # Close the input files
lines1 = set(text1) file1.close()
lines2 = set(text2) file2.close()
# Calculate the difference between the sets # Create a set of the lines in each file
lines1 = set(text1)
lines2 = set(text2)
# Calculate the difference between the sets
if len(lines1) > len(lines2):
diff = lines2.difference(lines1) diff = lines2.difference(lines1)
else:
diff = lines1.difference(lines2)
# Open the output file with open("diff.csv", "w", encoding="utf8") as ofile:
output_file = open("diff.csv", "w", encoding="utf8")
# Write the difference to the output file
for line in diff: for line in diff:
output_file.write(line) ofile.write(line)
# Close the output file
output_file.close()
if __name__ == "__main__":
main()