背景
在测试Web后台管理系统项目时,导入数据是个高频出现的功能,tablefill主要完成根据配置文件对模板进行填充数据
使用
安装
pip install tablefill
配置列数据类型
[
{
"type": "faker", // 可选值 faker(默认值,可不写type这个字段)、input 会直接读取var 的值 由自己设置
"func": "name", // 对应的是 Faker 生成虚拟数据的那些方法名 https://faker.readthedocs.io/en/master/providers.html
"var": null, // 没有参数时可以不写该字段, 当type 为faker时 这部分会被作为func 对应函数名的入参
"varFirst": "前", // 如果不需要可以不写该字段, 会在 var 这个 参数 前面 加上 内容
"varEnd": "后" // 如果不需要可以不写该字段, 会在 var 这个 参数 后面 加上 内容
}
]
api参考faker phone_number: 生成手机号 random_element: 列表中随机元素 name: 随机名称 ssn: 身份证号 date: 随机日期
示例
[
{
"type": "input",
"var": "这列我输入"
},
{
"func": "phone_number"
},
{
"func": "random_int",
"var": {
"min": 10,
"max": 21
},
"varFirst": "编号",
"varEnd": "班"
},
{
"func": "random_element",
"var": {
"elements": ["小学", "高中", "初中"],
}
}
]
导入模板文件
执行命令
# --num 可选参数 默认 10条 ,这里就是30条
fill generate 配置文件 模板文件 生成文件名 --num 30
fill generate "E:\coding\tablefill\examples\demo.json" "E:\coding\tablefill\examples\demo.xlsx" demo.xls
help
fill --help
Metadata
Release files for tablefill 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tablefill-0.2.0.tar.gz | 5.9 kB | Without provenance | Details for tablefill-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tablefill-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for tablefill-0.2.0-py3-none-any.whl |
Total release size: 12.4 kB
Release files / tablefill-0.2.0.tar.gz
| Download URL | tablefill-0.2.0.tar.gz |
|---|---|
| Size | 5.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e7cb4ca8efa431a13120c1e2767222e19d7c426ca98424017c90726f62fef78b
|
|
BLAKE2b-256 checksum How to use checksums |
be65c1a911e6b94fa59579ef726d1e323022cf2b86775a06044dd361feee09dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.4 Windows/10
|
Release files / tablefill-0.2.0-py3-none-any.whl
| Download URL | tablefill-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d16a058ef552133ec6a8cb347e1471bc2ae03713957bb82c041f1732a6d32d8f
|
|
BLAKE2b-256 checksum How to use checksums |
d4cabb81ea760e100f4df342a0a0360cdde3a7dff8f01c4198d53f564a93d13a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.9.4 Windows/10
|
Security for tablefill 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.