Back

Pylightxl处理Excel

1非常简单的excel处理软件,虽然没有xlrd等等那么功能强大,但是我觉得对我来说足够使用。

安装

1
pip install pylightxl

使用

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
# 导入
import pylightxl as xl
# 阅读excel文件可用ws参数指定表
# 例如:db = xl.readxl(fn='folder1/folder2/excelfile.xlsx', ws=('Sheet1','Sheet3'))
carddate = xl.readxl(fn="hbxl.xlsx")

#读取一列
print(len(carddate.ws(ws='Sheet1').col(col=3)))

#索引读取
mycards = []

for i in range(len(carddate.ws(ws='Sheet1').col(col=3)) - 1):
    mycards.append({'cardno': carddate.ws(ws='Sheet1').index(row=(i + 1), col=3),
                    'iccid': carddate.ws(ws='Sheet1').index(row=(i + 1), col=2),
                    'agent_id': 0, 'package_id': 77, 'rebate': 0})

print(mycards)

参考资料: https://pylightxl.readthedocs.io/en/latest/index.html

Licensed under CC BY-NC-SA 4.0