Class FlatFileGenerator
java.lang.Object
io.bloviate.file.FlatFileGenerator
- All Implemented Interfaces:
FileGenerator
Generator for creating flat files (CSV, TSV, pipe-delimited) with synthetic data.
The FlatFileGenerator creates delimited text files containing randomly generated data based on configurable column definitions. It supports multiple output formats including CSV, tab-delimited (TSV), and pipe-delimited files.
Key features:
- Support for CSV, TSV, and pipe-delimited output formats
- Configurable number of rows and columns
- Automatic header generation with column names
- Integration with
ColumnDefinitionandDataGenerator - YAML configuration export capability
Example usage:
List<ColumnDefinition> columns = Arrays.asList(
new ColumnDefinition("id", new IntegerGenerator(random)),
new ColumnDefinition("name", new StringGenerator(random))
);
new FlatFileGenerator.Builder("output-file")
.addAll(columns)
.rows(1000)
.output(new CsvFile())
.build()
.generate();
- Author:
- Tim Veil
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilds aFlatFileGenerator, defaulting to CSV output and1000rows with no columns. -
Method Summary
Modifier and TypeMethodDescriptionvoidgenerate()Generates the output data file, writing one header row followed by the configured number of data rows.Returns the column definitions, in output order.Returns the file format definition controlling the delimiter and extension.Returns the base output file name (the format-specific extension is appended at generation time).longgetRows()Returns the number of data rows to generate, excluding the header row.voidyaml()Exports this generator's configuration to a YAML file (named after the generator's base file name with a.yamlextension).
-
Method Details
-
generate
public void generate()Description copied from interface:FileGeneratorGenerates the output data file, writing one header row followed by the configured number of data rows.- Specified by:
generatein interfaceFileGenerator
-
yaml
public void yaml()Description copied from interface:FileGeneratorExports this generator's configuration to a YAML file (named after the generator's base file name with a.yamlextension).- Specified by:
yamlin interfaceFileGenerator
-
getFileName
Returns the base output file name (the format-specific extension is appended at generation time).- Returns:
- the base file name
-
getDefinition
Returns the file format definition controlling the delimiter and extension.- Returns:
- the file format definition
-
getColumnDefinitions
Returns the column definitions, in output order.- Returns:
- the column definitions
-
getRows
public long getRows()Returns the number of data rows to generate, excluding the header row.- Returns:
- the data row count
-