Skip to main content

Excel模板数据填充,快速应对Web项目数据导入

Project description

背景

在测试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 这个 参数 后面 加上 内容
  }
]

示例

[
  {
    "type": "input",
    "var": "这列我输入"
  },
  {
    "func": "phone_number"
  },
  {
    "func": "random_int",
    "var": {
      "min": 10,
      "max": 21
    },
    "varFirst": "编号",
    "varEnd": "班"
  },
  {
    "func": "random_elements",
    "var": {
      "elements": ["小学", "高中", "初中"],
      "length": 1
    }
  }
]

导入模板文件

需要是xlsx/xls文件 4h3G3F.md.png

执行命令

# --num 可选参数 默认 10条 ,这里就是30条
fill generate 配置文件 模板文件 生成文件名 --num 30 

fill generate "E:\coding\tablefill\examples\demo.json" "E:\coding\tablefill\examples\demo.xlsx"
 demo.xls

填充数据后的文件 4h8FbR.md.png

help

fill --help

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

tablefill-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

tablefill-0.1.1-py3-none-any.whl (4.9 kB view details)

Uploaded Python 3

File details

Details for the file tablefill-0.1.1.tar.gz.

File metadata

  • Download URL: tablefill-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.10 CPython/3.9.7 Windows/10

File hashes

Hashes for tablefill-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f5433c560b069ee415c17fabfd727ef5cd6057c09bf9a9f4aa7b334ceff6b971
MD5 51f7226a1ca6159d75869506141b31c0
BLAKE2b-256 b5ab44162d01b4baae80c5aae3c8424bba613ad6a90d6abf2f20778efd0c389b

See more details on using hashes here.

File details

Details for the file tablefill-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tablefill-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.10 CPython/3.9.7 Windows/10

File hashes

Hashes for tablefill-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7d6c53f5e676afcb6749cbff0495c09d41a44a99da1ab0c5d77fe8cf54bfe6b6
MD5 9d9b85dc232bad614f5dd5b0c5f07eb1
BLAKE2b-256 96ef3c4d7c778c4223686ed58fe7ba34c73e95def66bde3c9b7123ea78559a6b

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