Giter VIP home page Giter VIP logo

python-csv-test-data-generator's Introduction

Python CSV test data generator

This is a small script I made during my graduation internship with the purpose of conveniently generating test data in the form of CSV files.

Basic Usage

  1. If you don't have pipreqs installed:
$ pip3 install pipreqs
  1. Install the dependencies
$ pipreqs .
  1. Run the script. By default it will generate 10 rows and 3 columns and name the file test-data.csv
$ python3 python-csv-test-data-generator.py

Available commands

Argument Functionality
--name OR -n Give a custom name to the output file. The script does not check for file extension, so it's up to you to add it or not.
--columns OR -c Set a number of columns to generate.
--rows OR -r Set a number of rows to generate.
--customColumns OR -cc Set custom names for the columns.
--customWords OR -cw Use a set of custom words (it will choose words at random, when filling the cell).
--idColumn OR -i If set, will add an ID column to the output file as first column.
--useDictionary OR -d If set, will generate words from a dictionary (this takes longer to run than to use automatic/custom words). Note: if custom words were provided as one of the arguments, this flag will be ignored.
--customDelimiter OR -cd Set a custom delimiter that is not a comma.

Example

This command will generate a file called my-test-data.csv with 3 custom columns, an ID column, and 5 rows filled with words from a dictionary (please note that the dictionary functionality takes a little longer to generate the file).

$ python3 python-csv-test-data-generator.py -n my-test-data.csv -i -r 5 --cw apple orange banana cherry raspberry

OR a more verbose version

$ python3 python-csv-test-data-generator.py --name my-test-data.csv --idColumn --rows 5 --customWords apple orange banana cherry raspberry

NOTE: When trying to add a custom delimiter, make sure to use the following syntax in the command line:

$ python3 python-csv-test-data-generator.py -cd="|"

The output will look something like this:

ID Col 0 Col 1 Col 2
1 orange raspberry cherry
2 cherry banana raspberry
3 apple raspberry cherry
4 apple banana cherry

License

Built with โ™ฅ by Erik Naljota under MIT License

Acknowledgements

To make this script, I used RandomWord package by vaibhavsingh97 on Github and an answer by Greenstick on StackOverflow on a simple progress bar in Python.

python-csv-test-data-generator's People

Contributors

eriknaljota avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.