GithubHelp home page GithubHelp logo

datagen's Introduction

Data Generator

Thanks to @anarasimham for the python skeleton that was modifed for this data generator.

Here is the original data generation script:

https://github.com/anarasimham/data-gen

Overview

The data generater uses the faker python library to generate random values for each attribute in a given schema. The ouput of the script is json format. In the script there are 5 unique data generators:

  • CustomerDataGenerator
  • SalesRepDataGenerator
  • POSDataGenerator
  • POSCustomerDataGenerator
  • ManufacturingDataGenerator

The default data genenerator in the script is the POSDataGenerator.This can be modifed by changed the selected class used for generating the data.

To modifiy what data generator is used, modifiy the d variable to point to one of the 5 unique data generators listed above. To modify the number of records to produce, modify the rage defined in the for loop. In the example below, the data generator will product 20,000 records before terminating.

if __name__ == '__main__':
    d = POSDataGenerator()
    for i in range(1,20000):
        record = d.gen_row()
        record = json.dumps(record)
        producer.send(KAFKA_TOPIC, record)
        print(record)

A kafka producer has been included as well as a sleep timer that will regulate the data generation. The timer is defaulted to 1 json record per second but this can be adjusted as required.

Python Library Requirements (use pip to install dependencies):

random, json, time, datetime, faker kafka

Running the Script:

To run the script in the backgroud:

nohup python data-generator-kafka-producer.py &

To run the script and print to terminal:

python data-generator-kafka-producer.py

datagen's People

Contributors

jster1357 avatar

Watchers

James Cloos 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.