Skip to content

gorayni/CsvRandomSimulator

Repository files navigation

CSV Random Simulator

The simulator creates CSV files with random records by defining its fields and random distributions on a YAML properties file.

Requirements

The JAR file execution only requires Java 8 and the development requires Maven and optionally Eclipse. Additionally, the random variable dependencies visualization requires GraphViz.

How to build it

Once the code was downloaded, run the next command inside the project directory:

mvn compile
mvn assembly:assembly -DdescriptorId=jar-with-dependencies
mv target/csvSimulator-1.0-jar-with-dependencies.jar target/csvSimulator-1.0.jar

Aditionally, an eclipse project can be created by running:

mvn eclipse:eclipse

Simulator execution

The simulator needs a YAML configuration file that defines a CsvGenerator structure. For example, the next snippet shows the contents of greetings.yml:

!!com.csvsim.wrapper.CsvGenerator
fields:
- &id001 {name: greeting, type: STRING}
generator: !!com.csvsim.wrapper.String {field: *id001, discreteHistogram: {Hi: 0.4, Bye: 0.4, Au revoir: 0.2}}

This files defines a single field named greeting and its discrete distribution with three strings: "Hi", "Bye", and "Au revoir".

To simulate an infinite number of records run:

java -jar target/csvSimulator-1.0.jar -f greetings.yml

To simulate only five records run:

java -jar target/csvSimulator-1.0.jar -f greetings.yml -n 5

Both simulations can be run on a socket server, for example, to simulate 100 records and start the server on port 2020 type:

java -jar target/csvSimulator-1.0.jar -f greetings.yml -n 100 -p 2020

To test the server, open another terminal and run telnet on port 2020:

telnet localhost 2020

Finally, to create a field and random distribution dependency graph in DOT language run:

java -jar target/csvSimulator-1.0.jar -f greetings.yml -d greetings.dot

To create a SVG file run:

dot -Tsvg greetings.dot > greetings.svg

For instance, the next image shows the fields and random distributions of the 3.containers.yml example.

containers

Examples

The next example files are located in the main directory:

  • 0.helloWorld.yml
  • 1.fieldStructure.yml
  • 2.basicGenerators.yml
  • 3.containers.yml
  • 4.discreteEventDispatcher.yml

About

A CSV random generation simulator

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages