Skip to content

Commit

Permalink
Add sesseltjonna-csv
Browse files Browse the repository at this point in the history
  • Loading branch information
skjolber committed Sep 2, 2019
1 parent 5548b52 commit 7356b5b
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 24 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
29 changes: 6 additions & 23 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -350,33 +350,16 @@
<version>3.1.0-RELEASE</version>
</dependency>

<dependency>
<groupId>com.github.skjolber.sesseltjonna-csv</groupId>
<artifactId>parser</artifactId>
<version>1.0.17</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-patch-plugin</artifactId>
<version>1.2</version>
<configuration>

<!-- patches required for API changes in newer libraries -->

<patches>
<patch>esperio-csv-6.x.patch</patch>
<patch>flatpack-4.x.patch</patch>
</patches>
</configuration>
<executions>
<execution>
<id>patch</id>
<goals>
<goal>apply</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
public class Parsers {

private static final List<AbstractParser> parsers = Arrays.asList(
new DecsParser()
new DecsParser(), new SesseltjonnaParser()
);

private Parsers() {
Expand Down
Original file line number Diff line number Diff line change
@@ -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<String[]> reader = StringArrayCsvReader.builder().build(input);

String[] next;
do {
next = reader.next();
if(next == null) {
break;
}
process(next);
} while(true);
}

@Override
public List<String[]> parseRows(final Reader input) throws Exception {
CsvReader<String[]> reader = StringArrayCsvReader.builder().build(input);
List<String[]> 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;
}

}

0 comments on commit 7356b5b

Please sign in to comment.