differ
This commit is contained in:
@ -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.
|
||||
# If it doesn't. Call my number (It's hidden in your ear!).
|
||||
# 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
|
||||
|
||||
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()
|
||||
# Open the input files
|
||||
file1 = open("file1.csv", "r", encoding="utf8")
|
||||
file2 = open("file2.csv", "r", encoding="utf8")
|
||||
|
||||
# Close the input files
|
||||
file1.close()
|
||||
file2.close()
|
||||
# Read the contents of the input files into variables
|
||||
text1 = file1.readlines()
|
||||
text2 = file2.readlines()
|
||||
|
||||
# Create a set of the lines in each file
|
||||
lines1 = set(text1)
|
||||
lines2 = set(text2)
|
||||
# Close the input files
|
||||
file1.close()
|
||||
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)
|
||||
else:
|
||||
diff = lines1.difference(lines2)
|
||||
|
||||
# Open the output file
|
||||
output_file = open("diff.csv", "w", encoding="utf8")
|
||||
|
||||
# Write the difference to the output file
|
||||
with open("diff.csv", "w", encoding="utf8") as ofile:
|
||||
for line in diff:
|
||||
output_file.write(line)
|
||||
|
||||
# Close the output file
|
||||
output_file.close()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
ofile.write(line)
|
||||
|
Reference in New Issue
Block a user