Easy transform json 2 excel
Project description
[TOC]
介绍
json 转换成 excel 满足 报表业务需求
为什么需要这个模块:
1. 标准 2. 可能,真的很优雅。
好的功能
1. 标准化
安装方法
pip install json2excel
调用案例
from json2excel import Json2Excel
if __name__ == '__main__':
json2excel = Json2Excel(head_name_cols=["rank", "name"])
# print(json2excel.run('./test.json'))
jsons = [
{
"student_no": 1001,
"name": "James",
"score": 10,
"class": "A-1",
"rank": 1
},
{
"student_no": 1002,
"name": "Tome",
"score": 91,
"class": "A-1",
"rank": 2
},
]
print(json2excel.run(jsons))
参数介绍
json2excel 控制参数
format_handler 非必须 function/class 自定义json格式化函数,强烈推荐自定义 export_handler 非必须 class 自定义json输出成excel函数,一般不需要修改 export_dir 非必须 str 文件输出 **绝对** 路径,推荐自定义 head_name_cols 非必须 list 自定义excel表头排序,推荐自定义 kwargs 非必须 空 其他参数
自定义json转换函数说明
FormatHandler 可以是 类,或者函数。最重要的是把数据转换成如下格式。
"""
输出目标格式:
注意,一定需要转换成这种格式,才能正常保存。
[
{
"student_no": 1001,
"name": "James",
"score": 10,
"class": "A-1",
"rank": 1
},
{
"student_no": 1002,
"name": "Tome",
"score": 91,
"class": "A-1",
"rank": 2
},
]
"""
class FormatHandler:
def __init__(self, **kwargs):
""""""
def __call__(self, data_list: (list, dict)):
""""""
todo
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
json2excel-1.0.4.tar.gz
(3.8 kB
view details)
Built Distribution
File details
Details for the file json2excel-1.0.4.tar.gz
.
File metadata
- Download URL: json2excel-1.0.4.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4318148a591493bd2d65054cebcf6f20f29d77cb3f2a0875d720ee642852fefe |
|
MD5 | 5acb20c51098d3cfc4112c4dd24a917e |
|
BLAKE2b-256 | 9e66fddb0d03c807bf356d90c0c02684db658b46d1fb9bacfeab1d20f93bb73f |
File details
Details for the file json2excel-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: json2excel-1.0.4-py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: Python-urllib/3.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67cc6602078b2290fe4675e69c11d5d2d2f1cf0241f18f08e6754a4bbff12fda |
|
MD5 | a2aee41c002ef9ab4040b907dfc6ef0c |
|
BLAKE2b-256 | 9e47fa776375cc347b5d6c1bbb7f729af7da19fac8d9b5c6ff67e0dfbdc0a648 |