Skip to main content

这是一个Python编写的表格读写常用操作功能基础模块,使用了三种引擎进行封装,屏蔽各种引擎实现方式,统一方法

Project description

PythonXlsxManger

由于工作中偶尔需要编写一些表格数据处理脚本,而其中大部分代码都是重复的,所以为了更好的开发效率,我决定将日常表格管理脚本中用到的基础功能集合起来并使用开源都方式共享,同时也希望有更多人能够一起完善。

简介

PythonXlsxManger Gitee项目(Python Linux基础模块: pxm)是使用Python3基于现有openpyxl模块编写的表格读写基础模块,实现常用功能。 在模块设计上,借鉴了Shell语言管道的特性,可一步步截取数据(Cut开头的函数)

特色

  • 使用全中文注释,即使小白也能轻松上手
  • 完全开源、永久免费

使用方法

安装

具体可以访问Pypi项目地址https://pypi.org/project/pxm

pip3 install --upgrade pxm -i https://pypi.tuna.tsinghua.edu.cn/simple

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 ColorInfo3 import ColorLogger

from pxm 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

pxm-1.0.3.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

pxm-1.0.3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file pxm-1.0.3.tar.gz.

File metadata

  • Download URL: pxm-1.0.3.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.3

File hashes

Hashes for pxm-1.0.3.tar.gz
Algorithm Hash digest
SHA256 e7ba4ccb622ac080501e167009fc4ffd88f6909a8e68e3e11f870adb1a9d122b
MD5 082e12562031e85188dfde5132071ee1
BLAKE2b-256 f3bdcc084d011e8b9e864f352670e8ee73a30bfff7654c13e9d2d148c03663e2

See more details on using hashes here.

File details

Details for the file pxm-1.0.3-py3-none-any.whl.

File metadata

  • Download URL: pxm-1.0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.7.3

File hashes

Hashes for pxm-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 2010e717293238d6350252d5434ccb4dd797500bda8476de8d562998896ecd32
MD5 bad60347e72ad96d72c335fd0fa79346
BLAKE2b-256 aef51b5734d20dede72e5a6220747ea6e972a818f01935f185757f385a392fff

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page