42 lines
918 B
Python
42 lines
918 B
Python
|
import json
|
||
|
|
||
|
|
||
|
|
||
|
json_path = "/mnt/ssd1T/hoanglv/Projects/KIE/DATA/SS_Invoice/multi_page_vat/SL_HCM.json"
|
||
|
with open(json_path, 'r', encoding='utf8') as f:
|
||
|
data = json.load(f)
|
||
|
print(data[list(data.keys())[0]].keys())
|
||
|
|
||
|
keys = [
|
||
|
'serial_value',
|
||
|
'no_value',
|
||
|
'form_value',
|
||
|
'date',
|
||
|
|
||
|
'seller_company_name_value',
|
||
|
'seller_address_value',
|
||
|
'seller_mobile_value',
|
||
|
'seller_tax_code_value',
|
||
|
|
||
|
'buyer_name_value',
|
||
|
'buyer_company_name_value',
|
||
|
'buyer_address_value',
|
||
|
'buyer_mobile_value',
|
||
|
'buyer_tax_code_value',
|
||
|
|
||
|
'VAT_amount_value',
|
||
|
'total_in_words_value',
|
||
|
'total_value'
|
||
|
]
|
||
|
new_data = {}
|
||
|
for file_name, items in data.items():
|
||
|
|
||
|
new_items = {}
|
||
|
for k in keys:
|
||
|
new_items[k] = items[k]
|
||
|
new_data[file_name] = new_items
|
||
|
|
||
|
|
||
|
with open(json_path, 'w', encoding='utf8') as f:
|
||
|
json.dump(new_data, f, ensure_ascii=False)
|
||
|
|