Skip to main content

这是一个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 -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 src.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

pxm_liuyi778_stable-0.0.1.tar.gz (30.8 kB view details)

Uploaded Source

Built Distribution

pxm_liuyi778_stable-0.0.1-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file pxm_liuyi778_stable-0.0.1.tar.gz.

File metadata

  • Download URL: pxm_liuyi778_stable-0.0.1.tar.gz
  • Upload date:
  • Size: 30.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for pxm_liuyi778_stable-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8a6222b13ed957d7826756e8dc1e568360015e956d088d75d180374c61378610
MD5 bab91d4b84c4777bbea988ee6315d609
BLAKE2b-256 241fa4e52c39620981b5b3d31f90d985e4fd556b8c0643e140519c2bb6f91abc

See more details on using hashes here.

Provenance

File details

Details for the file pxm_liuyi778_stable-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pxm_liuyi778_stable-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 14d55ae594a63e4f571c50614eaee8f14b4e5ad31f374165a869c43fc616a35e
MD5 18abb1e1e997991fa70b9e6e6e3bcdd2
BLAKE2b-256 cf92a883188e4fb06a907226495598d435b283137687ba6ad385dea70958bc35

See more details on using hashes here.

Provenance

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