gen_data简介

gen_data简介

介绍

gen_data是一个方便的工具,支持生成csv测试数据文件。
它可以用来生成一个非常大的数据文件用于测试目的。

usage: gen_data [-h] -r rows [-c columns] [-t titles] csvfile

generate csv file with specfied number of rows, and column types.

positional arguments:
  csvfile

options:
  -h, --help            show this help message and exit
  -r rows, --rows rows  number of rows
  -c columns, --columns columns
                        list of colume type, in this format: "t t t:n ..." where t is type (number), n is column length.
  -t titles, --titles titles
                        list of column titles

list of supported types: bool=1 int=2 string=3 float=4 date=5 datetime=6

如何设置?

# clone the repo
git clone git@github.com:patfinder/gen_data.git

# move to the tool source folder. then enter below command to setup the tool.
# after this, gen_data will become a script command that you can execute directly.
$ pip install -e .

# show info of installed script
$ pip show gen_data
name: gen-data
version: 0.0.1
summary: a convinient tool for generating big test data.
home-page: https://github.com/patfinder/gen_data/
author: le vuong nguyen
author-email: vuong.se@gmail.com
license: unknown
location: ~/myrepos/gen_data
requires: 
required-by: 

用法

# Show Help for the command
$ gen_data --help

# Run sample command to generate csv with 5 rows
# and columns of (int, string, string with length of 20, int) and column titles
$ gen_data f1.csv -r 5 -c"1,3,3:20,2" -t"is_active,name,job_desc,score"

# Sample output of above command is f1.csv with below content
$ cat f1.csv 
id,is_active,name,job_desc,score
1,False,Louis Martinez,Really tonight we.,559
2,True,Larry Williams,Moment word camera.,845
3,True,Brandon Williams,Wear your consumer.,677
4,False,Chelsea Zamora,Identify itself let.,384
5,True,Jonathan Collier MD,Offer popular.,502

以上就是gen_data简介的详细内容,更多请关注www.sxiaw.com其它相关文章!