当前位置: 首页 > news >正文

制作社交app软件要多少钱上海seo博客

制作社交app软件要多少钱,上海seo博客,眉山网站优化,物联网概念现需将pdf 转换至Excel , 目前实现方式:将PDF的TABLE部分与 非 TABLE部分分别导出至Excel两个sheet中 1)、识别PDF中的表格块 2)、将PDF转换为Word格式 3)、提取Word中非表格的文本数据 4)、对文本与表格重…

现需将pdf 转换至Excel ,
目前实现方式:将PDF的TABLE部分与 非 TABLE部分分别导出至Excel两个sheet中
1)、识别PDF中的表格块
2)、将PDF转换为Word格式
3)、提取Word中非表格的文本数据
4)、对文本与表格重复的行进行去重
5)、合并导出至Excel不同sheet页中

# coding=UTF8
import datetime
from docx import Document
from pdf2docx import Converter
import pandas as pd
import numpy as np
import pdfplumber
import os
import fitz# TODO 输出PDF表格数据至Excel
def extractTables(filepath):with pdfplumber.open(filepath) as pdf:tables = []for i in range(0, len(pdf.pages)):page = pdf.pages[i]tables.append(page.extract_tables())df = pd.DataFrame()df_seperation = pd.DataFrame([np.nan, np.nan])  # 创建空白的,用于充当分隔行for i in range(0, len(tables)):tabular = tables[i]  # 选取第i页的表格if len(tabular) > 0:  # 如果该页存在表格的话for j in range(0, len(tabular)):  # j  表示第几个表格df_temp = pd.DataFrame(tabular[j])df = pd.concat([df, df_seperation, df_temp])  # 更新总表格return df# TODO pdf 转Word
def extractWord(pdffilepath, wordfilepath):cv = Converter(pdffilepath)cv.convert(wordfilepath)cv.close()# TODO 获取非表格内容
def getDocLines(wordfilepath):doc = Document(wordfilepath)paragraphs = doc.paragraphslines = []for paragraph in paragraphs:line = paragraph.text.strip()if not line:continuelines.append(line)# aspose用的体验板,带有页眉# lines = lines[100:]# print(lines)df = pd.DataFrame(lines)return df# TODO 删除与table重复的行数据
def txt(tabledf, txtdf):lines = []for line in tabledf[0]:lines.append(str(line))# 获取txt与Excel重复的数据repeat_txt = []for line in lines:for txt in txtdf[0]:if line.find(txt) != -1:repeat_txt.append(txt)txtdf = txtdf.drop(txtdf[txtdf[0] == txt].index)return txtdfif __name__ == '__main__':filepath = 'D:\develop_python\Python_Demo\PDF_TO_EXCEL\YM2021\\'outpath = 'D:\develop_python\Python_Demo\PDF_TO_EXCEL\YM2021\\'pdffile = '南通-2.21'pdffilepath = filepath + str(pdffile) + '.pdf'excelfilepath = filepath + str(pdffile) + '.xlsx'wordfilepath = filepath + str(pdffile) + '.docx'# 获取PDF表格数据try:starttime = datetime.datetime.now()print('执行开始', starttime)if not os.path.exists(outpath):os.makedirs(outpath)print()print('正在读取表格数据........')tabledf = extractTables(pdffilepath)print('表格数据读取完成........')print()print('正在转换Word......')extractWord(pdffilepath, wordfilepath)print('Word转换完成......')print()print('正在解析非表格文本数据......')txtdf = getDocLines(wordfilepath)# 删除与table重复的行数据df = txt(tabledf, txtdf)print('非表格数据解析完成......')print()print('正在输出Excel文件......')writer = pd.ExcelWriter(excelfilepath)tabledf.to_excel(writer, sheet_name='EXCEL', index=False)# txtdf.to_excel(writer, sheet_name='txt', index=False)df.to_excel(writer, sheet_name='txt', index=False)writer.save()print('Excel文件输出成功......')print()endtime = datetime.datetime.now()print('执行结束', endtime)print('耗时', endtime - starttime)except Exception  as e:print(Exception, e.args)
http://www.hkea.cn/news/848006/

相关文章:

  • 网站维护费用怎么收路由优化大师官网
  • 如何加入小说网站做打字员合肥网站优化推广方案
  • 网站建设现状关键词在线优化
  • 网站建设就业百度网址导航主页
  • 郑州公司做网站汉狮中囯联通腾迅
  • 专业网上购物平台优化网站的步骤
  • 用web开发一个网站怎么做网站推广优化平台
  • 建设企业网站进去无法显示搜索引擎seo
  • 网站 分辨率百度视频推广
  • 中国红河网seo排名工具
  • 做网站商丘3a汽车集团公司网络营销方案
  • 网络宣传推广策划范文seo如何优化排名
  • 网站 建设 原则新闻今天的最新新闻
  • 服装网站首页设计主要推广手段免费
  • 网站建设公司做销售好不好?seo搜索引擎优化实训总结
  • 江西威乐建设集团有限公司企业网站长春关键词优化公司
  • 深圳网站建设lxhd英文关键词seo
  • 在线购物商城网站百度移动端排名软件
  • 太原网站的公司友情链接的英文
  • 网站是用什么做的吗百度q3财报2022
  • 深圳福田网站建设公司如何做谷歌seo推广
  • 西安有做网站的吗北京网站设计公司
  • 哪家专门做特卖网站平台连接
  • 衢州网站推广最近发生的重大新闻
  • 网页设计的网站配色方案seo基础培训机构
  • 维护网站是什么工作淄博网站制作
  • 做电影下载网站成本淘宝关键词排名
  • 企业h5网站建设百度推广电话是多少
  • 中国保密在线网站培训系统软文怎么做
  • 山西住房城乡建设部网站整合网络营销是什么