Files
Trans_tools/Auto Trans/differ.py
2022-12-26 01:33:18 -03:00

38 lines
929 B
Python

#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.
# If it doesn't. Call my number (It's hidden in your ear!).
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
text1 = file1.readlines()
text2 = file2.readlines()
# Close the input files
file1.close()
file2.close()
# Create a set of the lines in each file
lines1 = set(text1)
lines2 = set(text2)
# Calculate the difference between the sets
diff = lines2.difference(lines1)
# Open the output file
output_file = open("diff.csv", "w", encoding="utf8")
# Write the difference to the output file
for line in diff:
output_file.write(line)
# Close the output file
output_file.close()
if __name__ == "__main__":
main()