Directives control aspects of the CSV file's appearance or format, but not its content. Each directive is a single command entered on its own line. Directives can be omitted entirely and the default CSV behaviour will be used: 10 rows, as many columns as you define, no header, etc.
Any line of text in the recipe is treated as a column definition unless it corresponds with any of the following exclusions …
- Lines that are directives
- Blank or empty lines
- Lines starting with // which are treated as comments
The simplest column definition is a string, for instance a line reading hello world will cause this string to be used as the value for a column on every row of the output. The left-most column is defined first when reading the recipe from top-to-bottom.
Variables
Variables are declared in the variables pane and can be reused as often as is needed.
Declare a variable by typing key = value in the variables pane. Use a variable by including $key in the recipe to see value in the CSV output.
CSVs created using only strings and variables will be quite boring since all the rows will be the same. Patterns are one way of introducing randomised or dynamic content, particularly concerned with strings such as serial or telephone numbers, codes strings, vehicle registrations, and so on.
Using patterns
Patterns are declared in the variables pane in the normal fashion.
foo = {111}-{AAA*}
To include the output of a pattern in a column of the CSV, invoke it with %. Invoking a pattern with $ will do so as if it were a variable and will simply reproduce its definition.
%foo
When invoked with %, the pattern text is included verbatim but …
- any 1 character appearing between a { and a } will be replaced with a random digit.
- any A character appearing between a { and a } will be replaced with a random uppercase letter.
- any * character appearing between a { and a } will be replaced with a random digit or uppercase letter.
- 123-ABC1
- 443-QRTX
- 263-BHCH
- 881-LIM9
Functions add specialised random content to a column. They are preceded with an @ symbol and accept parameters delimited by ( and ). Functions can be called from column definitions directly or used in variable values.
csvhorse
csvhorse generates CSV files from simple recipes typed in the left-hand pane. CSV output appears on the right when the recipe is run. There is support for variables and functions for counting, random numbers, Lorem Ipsum, dates, and more …
Officially on the web at csvhorse.mcglashan.net
All the source code on github at github.com/davidmcglashan/csvhorse (CC0 1.0 Universal)