Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ This list might be outdated. Please check the individual filter classes for deta
* Cities
* Counties
* Hospitals
* Hospital Abbreviations
* States
* State Abbreviations

Expand Down

This file was deleted.

38 changes: 0 additions & 38 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
<commons.collections4.version>4.5.0</commons.collections4.version>
<commons.lang3.version>3.20.0</commons.lang3.version>
<commons.codec.version>1.19.0</commons.codec.version>
<commons.csv.version>1.14.0</commons.csv.version>
<commons.io.version>2.21.0</commons.io.version>
<commons.text.version>1.15.0</commons.text.version>
<commons.validator.version>1.10.1</commons.validator.version>
Expand All @@ -51,7 +50,6 @@
<gson.version>2.13.2</gson.version>
<httpclient.version>5.6</httpclient.version>
<json.version>20251224</json.version>
<junit.version>5.11.3</junit.version>
<junit.pioneer.version>2.3.0</junit.pioneer.version>
<libphonenumber.version>9.0.21</libphonenumber.version>
<log4j.version>2.25.3</log4j.version>
Expand All @@ -60,7 +58,6 @@
<maven.surefire.version>3.5.4</maven.surefire.version>
<mockito.version>5.20.0</mockito.version>
<pdfbox.version>3.0.6</pdfbox.version>
<snakeyaml.version>2.5</snakeyaml.version>
</properties>
<build>
<plugins>
Expand Down Expand Up @@ -339,21 +336,6 @@
<artifactId>pdfbox</artifactId>
<version>${pdfbox.version}</version>
</dependency>
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-core</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>com.github.jai-imageio</groupId>
<artifactId>jai-imageio-jpeg2000</artifactId>
<version>1.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>jbig2-imageio</artifactId>
<version>3.0.4</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand All @@ -378,20 +360,6 @@
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.mifmif</groupId>
<artifactId>generex</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>${snakeyaml.version}</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand All @@ -410,11 +378,5 @@
<version>${junit.pioneer.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
48 changes: 0 additions & 48 deletions qodana.yaml

This file was deleted.

107 changes: 107 additions & 0 deletions src/main/java/ai/philterd/phileas/data/CsvGenerator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
/*
* Copyright 2026 Philterd, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package ai.philterd.phileas.data;

import java.io.PrintWriter;
import java.io.Writer;
import java.util.LinkedHashMap;
import java.util.Map;

/**
* Generates a CSV of generated data.
*/
public class CsvGenerator {

private final Map<String, DataGenerator.Generator<?>> columns;
private String delimiter = ",";
private boolean useQuotes = false;

/**
* Creates a new CSV generator.
*/
public CsvGenerator() {
this.columns = new LinkedHashMap<>();
}

/**
* Sets the delimiter for the CSV.
* @param delimiter The delimiter.
* @return The {@link CsvGenerator} instance.
*/
public CsvGenerator withDelimiter(final String delimiter) {
this.delimiter = delimiter;
return this;
}

/**
* Sets whether or not to use quotes around all values.
* @param useQuotes Whether or not to use quotes.
* @return The {@link CsvGenerator} instance.
*/
public CsvGenerator withQuotes(final boolean useQuotes) {
this.useQuotes = useQuotes;
return this;
}

/**
* Adds a column to the CSV.
* @param name The name of the column.
* @param generator The generator for the column's data.
* @return The {@link CsvGenerator} instance.
*/
public CsvGenerator addColumn(final String name, final DataGenerator.Generator<?> generator) {
columns.put(name, generator);
return this;
}

/**
* Generates the CSV data.
* @param writer The {@link Writer} to write the CSV data to.
* @param rows The number of rows to generate.
*/
public void generate(final Writer writer, final int rows) {
final PrintWriter printWriter = new PrintWriter(writer);

// Write the header
final String header = String.join(delimiter, columns.keySet().stream().map(this::escapeCsv).toList());
printWriter.println(header);

// Write the rows
for (int i = 0; i < rows; i++) {
final StringBuilder row = new StringBuilder();
int colIndex = 0;
for (final DataGenerator.Generator<?> generator : columns.values()) {
final Object value = generator.random();
row.append(escapeCsv(String.valueOf(value)));
if (colIndex < columns.size() - 1) {
row.append(delimiter);
}
colIndex++;
}
printWriter.println(row);
}

printWriter.flush();
}

private String escapeCsv(String value) {
if (useQuotes || value.contains(delimiter) || value.contains("\"") || value.contains("\n") || value.contains("\r")) {
return "\"" + value.replace("\"", "\"\"") + "\"";
}
return value;
}

}
Loading
Loading