我使用OCR从pdf中读取发票,并能够以字符串格式提取它们。 现在我想以Json格式存储在数据库中
以下是我能够通过以下方式提取密钥和值的输入:
keys_=["None" if x == '' else x for x in unclean_data[2].lower().split(',')]
print(keys_)
key_: ['units ', 'item code ', 'description ', 'unit price (inc-gst) ', 'discount % ', 'total (inc-gst) ', 'None']
values_=["None" if x == '' else x for x in unclean_data[3].lower().split(',')]
print(values_)
value_: ['31.68 ', 'vhc ', 'amstel blanco 60x120 ', '$39.60 ', 'None', '$1', '254.53 ', 'None']
现在使用res_two=dict(zip(key_u,values_u))我可以转换它,但我想在输入中使用正则表达式搜索键,并用输出中显示的键替换它
示例**enter code here**
“商品代码”、“说明”、“数量”、“单价”、“价值”、“折扣%”、“总计(包括商品及服务税)”
Input = Table: Table_1
Units ,Item Code ,Description ,Unit Price (inc-GST) ,Discount % ,Total (inc-GST) ,
31.68 ,VHC ,Amstel Blanco 60x120 ,$39.60 ,,$1,254.53 ,
1 ,D0001 ,Delivery Charge ,$145.00 ,,$145.00 ,
Expected Output = {
"Item_Code":"VHC",
"Description":"Amstel Blanco 60x120",
"Quantity":3,
"Unit_price_ex_GST":$39.60 ,
"Value_ex_GST":40.91,
"GST":'',
"Discount%":'',
"Total(Inc_GST)":$1,254.53 },
目前没有回答
相关问题 更多 >
编程相关推荐