这是一个Python编写的表格读写常用操作功能基础模块,基于openpyxl封装常用功能
Project description
PythonXlsxManger
由于工作中偶尔需要编写一些表格数据处理脚本,而其中大部分代码都是重复的,所以为了更好的开发效率,我决定将日常表格管理脚本中用到的基础功能集合起来并使用开源都方式共享,同时也希望有更多人能够一起完善。
简介
PythonXlsxManger Gitee项目(Python Linux基础模块: pxm)是使用Python3基于现有openpyxl模块编写的表格读写基础模块,实现常用功能。
在模块设计上,借鉴了Shell语言管道的特性,可一步步截取列、行数据(Cut开头的函数)
特色
- 使用全中文注释,即使小白也能轻松上手
- 完全开源、永久免费
使用方法
安装
具体可以访问Pypi项目地址https://pypi.org/project/pxm
pip3 install --upgrade pxm-liuyi778-Stable
Demo
读取
#!/usr/bin/env python3
# -*- encoding: utf-8 -*-
"""
@File : demo.py
@Time : 2023-02-17 23:36
@Author : 坐公交也用券
@Version : 1.0
@Contact : faith01238@hotmail.com
@Homepage : https://liumou.site
@Desc : 当前文件作用
"""
from ColorInfo import ColorLogger
from pxm_liuyi778_Stable import Read
class Demo:
def __init__(self, filename="xls/demo.xlsx"):
"""
:param filename:
"""
self.filename = filename
self.logger = ColorLogger(class_name=self.__class__.__name__)
self.r = Read(filename=self.filename) # 读取文件
self.r.Set(sheet_index=1) # 设置Sheet索引值1(也就是第二个Sheet)
self.r.GetAll() # 获取所有数据
def all(self):
if self.r.Err:
self.logger.error("读取失败: ", r.Err)
else:
self.logger.info("数据读取成功")
print(self.r.DataR)
def line(self):
data = self.r.CutLine(0) # 截取第一行并获取最终结果
print("第一行的数据: ", data.DataR)
def start(self):
self.all()
self.line()
self.info()
def info(self):
print(f"当前工作簿数据总列数: {self.r.InfoCols}")
print(f"当前工作簿数据总行数: {self.r.InfoRows}")
print(f"当前工作簿索引值: {self.r.InfoSheet}")
print(f"当前工作簿名称: {self.r.InfoSheetName}")
if __name__ == "__main__":
d = Demo()
d.start()
效果
2023-02-21 11:17:14 demo.py line: 33 - Class: Demo Function: all - INFO : 数据读取成功
[['专业', '人数'], ['网络', 3], ['安全', 3]]
第一行的数据: ['专业', '人数']
当前工作簿数据总列数: 2
当前工作簿数据总行数: 3
当前工作簿索引值: 1
当前工作簿名称: Sheet2
问题反馈
点击链接加入QQ群聊【坐公交也用券】
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pxm_liuyi778_stable-1.0.3.tar.gz.
File metadata
- Download URL: pxm_liuyi778_stable-1.0.3.tar.gz
- Upload date:
- Size: 31.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec70f3652511c3ebda6e79c7d849f3af4adc29fd4e36ec2ca048db7eea5457e0
|
|
| MD5 |
022fff1f8faa446425d30085a543df1a
|
|
| BLAKE2b-256 |
4c4f9fec7439b31dcbdf3a8e188ef5df1a69163c26864a32d4318bedbd58f9c9
|
File details
Details for the file pxm_liuyi778_stable-1.0.3-py3-none-any.whl.
File metadata
- Download URL: pxm_liuyi778_stable-1.0.3-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94bd13189a02e3e69bb9e819775ce738d9602ed6d351ef2a23eb037f4967a48d
|
|
| MD5 |
44b380bdf08c00e7b3cb769421bc84cc
|
|
| BLAKE2b-256 |
af02bcf9b9a7c160d3b60e027c6812f5bee8bc2f2e8581bc79c9db40c735fc18
|