Skip to main content

Extract data from excel file, and export to json, msgpack, or any code(mako template).

Project description

简介

提取 Excel 里的数据,导出为各种结构化的文本。除了提供命令行下的可执行脚本外也提供了 Python API。

繁介

你总会需要一些由非技术人员提供的数据来充实你的程序内容,比如美术资源和各种数值。美术资源好说, 规范好目录和文件名就万事大吉了,但数值咋放呢?必须得有一个他懂、你懂、程序也懂的数值载体, 除了 Excel 估计你也没得选了,总不能指望人家跑来编辑什么 json、xml 之类的结构化文本吧?何况 Excel 本身就是个强大的数据处理工具,拿它来做数值易如反掌。于是本项目应运而生,专门用于提取 Excel 里的数据。

特性

  • 尽量约定而非配置,只需标出列名就能满足基本要求,高级玩法也只需要一点点小配置而已。 :stuck_out_tongue_winking_eye:
  • 支持多种数据结构 e.g. list,dict, (tree还有待实现)。
  • 支持导出为 json 格式
  • 支持使用 mako 生成代码

运行依赖

  • Python3

安装

$ python setup install

使用

Python API示例

from excel2xx import Excel

fpath = "abc.xls"
excel = Excel(fpath)

# 获取第一个 sheet 的内容
sheet = excel[0]
for row in sheet:
    print(row)
    
# 根据 sheet 名获取
sheet = excel["你好啊"]
for row in sheet:
    print(row)

CLI 示例

$ excel2xx json example/test.xls  -o example/test.json
$ excel2xx msgpack example/test.xls --output example/test.msgpack
$ excel2xx mako example/test.xls  -o example/test.lua --template example/test.mako

TODO

  • Simple DSL (just coding with python :stuck_out_tongue_winking_eye:)
  • Export to Lua code
  • Export to SQL code

LICENSE

WTFPL
            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                    Version 2, December 2004

 Copyright (C) 2014-2021 cupen<xcupen@gmail.com>

 Everyone is permitted to copy and distribute verbatim or modified
 copies of this license document, and changing it is allowed as long
 as the name is changed.

            DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

  0. You just DO WHAT THE FUCK YOU WANT TO.

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

excel2xx-0.6.0.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

excel2xx-0.6.0-py2.py3-none-any.whl (11.1 kB view hashes)

Uploaded Python 2 Python 3

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