01 python VS node 操作表格
• python 利用扩展库:
这两个支持的是xls旧版本的操作
1 | pip3 install xlrd #支持excel读取(xls) |
支持excel2010 xlsx/xlsm/xltx/xltm
1 | pip install openpyxl |
http://www.python-excel.org/ This site contains pointers to the best information available about working with Excel files in the Python programming language.
上面站点里面列出了较为popular 的 python处理excel文件的包
1 | import xlwt |
• node 利用npm包(sheetjs-xlsx, github里面xlsx相关star最多的项目):
1 | npm install xlsx // https://www.npmjs.com/package/xlsx |
总结扩展
• 开放了API的Office套件,都可以通过操作API来实现想要的重复的,有逻辑的操作
• 可以了解下open XML,Microsoft Office 中
Tips:
• 命令行操作:
man ls
ctrl + a 跳到行首
ctrl + e 跳到行末
ctrl + u 删除行首到光标位置
ctrl + k 删除行尾到光标位置
mv/rename重命名
rename需要homebrew安装
• Python相关
pip list | grep xlwt
Path,PurePath
文档参考
https://github.com/python/cpython/tree/3.9/Lib/pathlib.py
https://docs.python.org/zh-cn/3/library/pathlib.html
• 问题解决
Traceback (most recent call last):
File “xlwt.py”, line 1, in
import xlwt
File “/Users/py/xlwt.py”, line 13, in
workbook = xlwt.Workbook(encoding=’utf-8’)
AttributeError: module ‘xlwt’ has no attribute ‘Workbook’
文件名和导入的模块名不能是一样的