html table 批量转 Excel(xlsx)
Translation pending: this page is scaffold content and keeps original Chinese content for reference.
由于实验设备导出的数据为 html 格式,单个 html 文件达到 10-200M。采用 python 脚本,批量将 html 中的 table 批量转为 Excel,并导出到文件。
主要流程
- 采用
Beautifulsoup 4库进行解析,获取html中的table;
- 采用
- 采用
pandas解析table库中的数据,并进行整合;
- 采用
- 将整合后的
DataFrame导出到各Sheet,并保存到文件。
- 将整合后的

依赖包
bs4pandas
主要代码
1 | from bs4 import BeautifulSoup |
Author
Dorad, ddxid@outlook.com
All articles on this blog are licensed under CC BY-NC-SA 4.0 unless otherwise stated.
Comments



![[徒步]宁波九龙爱心线](https://i.cuger.cn/b/d3c7f637-f0a4-4cfb-8e2b-23631aaba006.jpg)


![[出差]内蒙草原风光](https://i.cuger.cn/b/0039bc8f-15e8-4039-a286-9fb1d1af9e33.jpg)