Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add sesseltjonna-csv #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}