-
-
Save me-suzy/65728e24dd95ec837f3b87a2f99c398d to your computer and use it in GitHub Desktop.
Afiseaza diferente intre numerele din categorii, din RO si EN
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import os | |
def load_json(file_path): | |
with open(file_path, 'r', encoding='utf-8') as file: | |
return json.load(file) | |
def compare_json_files(file1_path, file2_path): | |
data1 = load_json(file1_path) | |
data2 = load_json(file2_path) | |
# Creăm dicționare pentru acces rapid | |
dict1 = {item['html_file']: item['line_count'] for item in data1} | |
dict2 = {item['html_file']: item['line_count'] for item in data2} | |
differences = [] | |
# Comparăm valorile line_count | |
for html_file in dict1.keys(): | |
if html_file in dict2: | |
if dict1[html_file] != dict2[html_file]: | |
differences.append({ | |
'html_file': html_file, | |
'ro_count': dict1[html_file], | |
'en_count': dict2[html_file] | |
}) | |
else: | |
print(f"Warning: {html_file} not found in the English file.") | |
for html_file in dict2.keys(): | |
if html_file not in dict1: | |
print(f"Warning: {html_file} not found in the Romanian file.") | |
return differences | |
# Căile către fișierele JSON | |
ro_file = r"e:\Carte\BB\17 - Site Leadership\Principal 2022\ro\categorii.json" | |
en_file = r"e:\Carte\BB\17 - Site Leadership\Principal 2022\en\categorii.json" | |
# Comparăm fișierele | |
differences = compare_json_files(ro_file, en_file) | |
# Afișăm diferențele | |
print("Diferențe în line_count între fișierele RO și EN:") | |
for diff in differences: | |
print(f"File: {diff['html_file']}") | |
print(f" RO count: {diff['ro_count']}") | |
print(f" EN count: {diff['en_count']}") | |
print(f" Difference: {abs(diff['ro_count'] - diff['en_count'])}") | |
print() | |
print(f"Total diferențe găsite: {len(differences)}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment