Sum fixes
This commit is contained in:
@ -88,8 +88,8 @@ with open('original.csv', 'r', encoding='utf-8') as input_file, \
|
||||
# Calculate the estimated time remaining to translate the whole file
|
||||
time_remaining = avrg(times) * (length - i)
|
||||
|
||||
print(f'{Fore.RED}Original: {Fore.RESET}{row[0]} | {Fore.GREEN}Translation: {Fore.RESET}{translation.text}{" "*10}\n{Fore.CYAN}Estimated time remaining: {str(time_remaining).split(".")[0]}', end="\r")
|
||||
print(f'{Fore.RED}Original: {Fore.RESET}{row[0]} | {Fore.GREEN}Translation: {Fore.RESET}{translation}{" "*10}\n{Fore.CYAN}Estimated time remaining: {str(time_remaining).split(".")[0]}', end="\r")
|
||||
|
||||
writer.writerow([row[0], translation.text])
|
||||
writer.writerow([row[0], translation])
|
||||
|
||||
print(f"\n\n{Fore.YELLOW}FINISHED")
|
||||
|
@ -3,24 +3,35 @@
|
||||
#... 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!).
|
||||
|
||||
import csv
|
||||
def main():
|
||||
# Open the input files
|
||||
file1 = open("file1.csv", "r", encoding="utf8")
|
||||
file2 = open("file2.csv", "r", encoding="utf8")
|
||||
|
||||
def compare_csv_files(file1, file2):
|
||||
# read the files line by line and store them in sets
|
||||
with open(file1, 'r') as f1:
|
||||
lines1 = set(f1.readlines())
|
||||
with open(file2, 'r') as f2:
|
||||
lines2 = set(f2.readlines())
|
||||
# Read the contents of the input files into variables
|
||||
text1 = file1.readlines()
|
||||
text2 = file2.readlines()
|
||||
|
||||
# find the lines that are present only in one of the files
|
||||
only_in_file1 = lines1 - lines2
|
||||
only_in_file2 = lines2 - lines1
|
||||
# Close the input files
|
||||
file1.close()
|
||||
file2.close()
|
||||
|
||||
# write the lines to a new file
|
||||
with open('comparison_result.csv', 'w') as result_file:
|
||||
writer = csv.writer(result_file)
|
||||
writer.writerows(only_in_file1)
|
||||
writer.writerows(only_in_file2)
|
||||
# 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)
|
||||
|
||||
compare_csv_files('file1.csv', 'file2.csv')
|
||||
# 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()
|
||||
|
Reference in New Issue
Block a user