Skip to content

Commit

Permalink
Instantiate the CSV parser only once
Browse files Browse the repository at this point in the history
  • Loading branch information
BartChris committed Mar 23, 2024
1 parent 8fd8d1c commit dffbffb
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,13 @@ public List<String> getLines(UploadedFile file) throws IOException {
*/
public List<CsvRecord> parseLines(List<String> lines, String separator) throws IOException, CsvValidationException {
List<CsvRecord> records = new LinkedList<>();
CSVParser parser = new CSVParserBuilder()
.withSeparator(separator.charAt(0))
.withQuoteChar('\"')
.build();
for (String line : lines) {
if (!Objects.isNull(line) && !line.isBlank()) {
List<CsvCell> cells = new LinkedList<>();
CSVParser parser = new CSVParserBuilder()
.withSeparator(separator.charAt(0))
.withQuoteChar('\"')
.build();
CSVReader csvReader = new CSVReaderBuilder(new StringReader(line))
.withSkipLines(0)
.withCSVParser(parser)
Expand Down

0 comments on commit dffbffb

Please sign in to comment.