32 lines
832 B
Python
32 lines
832 B
Python
|
|
# This diffs two csv files, It's useful for mods and stuff.
|
|
# 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
|
|
|
|
|
|
# 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
|
|
if len(lines1) > len(lines2):
|
|
diff = lines2.difference(lines1)
|
|
else:
|
|
diff = lines1.difference(lines2)
|
|
|
|
with open("diff.csv", "w", encoding="utf8") as ofile:
|
|
for line in diff:
|
|
ofile.write(line)
|