PYTHON如何调取OCR识别模块识别发票并输出到EXCLE?
import qqai
from os import path
from win32com.client import Dispatch
import os
from datetime import datetime
def file_path():
global path_this_file
path_this_file = path.abspath('.') "\\"
global path_excel
path_excel = path_this_file '信息导.xlsx'
global path_pic_file
path_pic_file = path_this_file '照片'
def get_pic_name():
pic_list = []
for pic in os.listdir(path_pic_file):
pic_path = path_pic_file '\\' pic
pic_list.append(pic_path)
return pic_list
def HandwritingOCRImage(filename):
robot = qqai.vision.ocr.HandwritingOCR(app_id, app_key)
useless_list = ['登记表']
value_list = []
with open(filename, 'rb') as image_file:
result = robot.run(image_file)
item_list = result['data']['item_list']
for value in item_list:
words= value['itemstring']
if words in useless_list:
continue
else:
value_list.append(words)
return value_list
def get_useful_list(value_list):
key_list = ['姓名', '性别', '出生日期', '/地区', '民族', '职业', '手码', '固定电话', '证件类型', '证件有效期限', '证件', '通讯地址', '邮编']
useful_list = []
for words in value_list:
if words in key_list:
key_index = value_list.index(words)
next_index = key_index 1
if value_list[next_index] in key_list:
useful_list.append('')
else:
if words == '证件号码':
ID_NUM = "'" str(value_list[next_index]) #这边是为了避免科学计数法的问题
useful_list.append(ID_NUM)
else:
useful_list.append(value_list[next_index])
else:
continue
return useful_list
def put_into_excel(useful_list):
xl = Dispatch("Excel.Application")
xl.Visible = False # True是显示, False是隐藏
xl.DisplayAlerts = 0
excel_input = xl.Workbooks.Open(path_excel)
sheet = excel_input.Sheets('Sheet1')
max_row = sheet.UsedRange.Rows.Count
values = len(useful_list)
for i in range(values):
sheet.Cells(max_row 1, i 1).Value = str(useful_list[i])
excel_input.Save()
excel_input.Close()
xl.quit()
starttime = datetime.now()
"""腾讯AI开放平台 图片识别"""
app_id = '2110179251'
app_key = '******'
"""app_id , app_key 可以自己去腾讯AI开放平台注册,是免费的"""
file_path()
pic_list = get_pic_name()
for filename in pic_list:
value_list =HandwritingOCRImage(filename)
useful_list = get_useful_list(value_list)
put_into_excel(useful_list)
endtime = datetime.now()
total_time = (endtime - starttime).seconds
print(">>>成功录入信息{}条,总共耗时{}秒!".format(len(pic_list),total_time))
汉王ocr怎么 把扫描文件转换成EXCEL
汉王OCR只能对文字进行识别,识别生生成TXT文件。如果楼主需要生成EXCEL,只能自己根据识别后的文字重新创建。
汉王ocr怎么 把扫描文件转换成EXCEL
汉王OCR只能对文字进行识别,识别生生成TXT文件。如果楼主需要生成EXCEL,只能自己根据识别后的文字重新创建。
ocr文字识别excel
汉王OCR只能对文字进行识别,识别生生成TXT文件。如果楼主需要生成EXCEL,只能自己根据识别后的文字重新创建。
扫描的文件 ocr能识别然后生成excel文件吗
OCR表格的识别率不太高
有没有能将图片转换成excel的 ocr文字识别软件
有的,能将图换成Excel表格的ocr识别,其实搜索相关关键词“ocr文字识别软件”,也可以直接搜索“迅捷办公”,进入官网,里面有一个文字识别软件,可以帮助您将图片转换成Excel表格;
使用上面的ocr文字识别软件的方法其实很简单,如:打开文字识别---极速识别---添加文件---开始识别,这样就行啦,希望可以帮助到您吧。