diff --git a/README.md b/README.md index 41ce545..2111a12 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,7 @@ This is the list of all parsers currently tested. | SimpleFlatMapper CSV parser | 3.15.9 | [github.com/arnaudroger/SimpleFlatMapper](https://github.com/arnaudroger/SimpleFlatMapper) | | Diergo Easy CSV Streamable | 3.1.0 | [github.com/aburmeis/decs](https://github.com/aburmeis/decs) | | Product Collections | 1.4.5 | [github.com/marklister/product-collections](https://github.com/marklister/product-collections) | +| Sesseltjonna-csv | 1.0.11 | [github.com/skjolber/sesseltjonna-csv](https://github.com/skjolber/sesseltjonna-csv) | ## Statistics (updated 28th of February, 2018) diff --git a/pom.xml b/pom.xml index 8660f6a..a8e9032 100644 --- a/pom.xml +++ b/pom.xml @@ -350,33 +350,16 @@ 3.1.0-RELEASE + + com.github.skjolber.sesseltjonna-csv + parser + 1.0.17 + + - - org.apache.maven.plugins - maven-patch-plugin - 1.2 - - - - - - esperio-csv-6.x.patch - flatpack-4.x.patch - - - - - patch - - apply - - - - - org.apache.maven.plugins maven-compiler-plugin diff --git a/src/main/java/com/univocity/articles/csvcomparison/parser8/Parsers.java b/src/main/java/com/univocity/articles/csvcomparison/parser8/Parsers.java index 23bff68..644ea22 100644 --- a/src/main/java/com/univocity/articles/csvcomparison/parser8/Parsers.java +++ b/src/main/java/com/univocity/articles/csvcomparison/parser8/Parsers.java @@ -24,7 +24,7 @@ public class Parsers { private static final List parsers = Arrays.asList( - new DecsParser() + new DecsParser(), new SesseltjonnaParser() ); private Parsers() { diff --git a/src/main/java/com/univocity/articles/csvcomparison/parser8/SesseltjonnaParser.java b/src/main/java/com/univocity/articles/csvcomparison/parser8/SesseltjonnaParser.java new file mode 100644 index 0000000..0022896 --- /dev/null +++ b/src/main/java/com/univocity/articles/csvcomparison/parser8/SesseltjonnaParser.java @@ -0,0 +1,55 @@ +package com.univocity.articles.csvcomparison.parser8; + +import java.io.File; +import java.io.Reader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.github.skjolber.stcsv.CsvReader; +import com.github.skjolber.stcsv.builder.StringArrayCsvReaderBuilder; +import com.github.skjolber.stcsv.sa.StringArrayCsvReader; +import com.github.skjolber.stcsv.sa.rfc4180.RFC4180StringArrayCsvReader; +import com.univocity.articles.csvcomparison.parser.AbstractParser; + +public class SesseltjonnaParser extends AbstractParser { + + public SesseltjonnaParser() { + super("Sesseltjonna-csv databinding"); + } + + @Override + public void processRows(final Reader input) throws Exception { + CsvReader reader = StringArrayCsvReader.builder().build(input); + + String[] next; + do { + next = reader.next(); + if(next == null) { + break; + } + process(next); + } while(true); + } + + @Override + public List parseRows(final Reader input) throws Exception { + CsvReader reader = StringArrayCsvReader.builder().build(input); + List arrayList = new ArrayList<>(10000); + + String[] next; + do { + next = reader.next(); + if(next == null) { + break; + } + // the same array is returned, so make a copy + String[] copy = new String[next.length]; + System.arrayCopy(next, 0, copy, 0, next.length); + arrayList.add(copy); + } while(true); + + return arrayList; + } + +}