Skip to content
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ GroovyCSV is available through Maven Central.
## Dependencies

* [Groovy 1.8.x](http://groovy.codehaus.org) or later
* [OpenCSV 4.x](http://opencsv.sourceforge.net/)
* [OpenCSV 5.x](http://opencsv.sourceforge.net/)


Many thanks to everyone who's contributed to the project and everyone in the OpenCSV team for
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repositories {
}

dependencies {
compile 'com.opencsv:opencsv:4.0'
compile 'com.opencsv:opencsv:5.0'
compileOnly 'org.codehaus.groovy:groovy-all:1.8.8'
testCompile 'org.spockframework:spock-core:1.1-groovy-2.4-rc-2'
testCompile 'cglib:cglib-nodep:2.2'
Expand Down
24 changes: 20 additions & 4 deletions src/com/xlson/groovycsv/CsvParser.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package com.xlson.groovycsv

import com.opencsv.CSVParser
import com.opencsv.CSVReader
import com.opencsv.ICSVParser
import com.opencsv.validators.LineValidatorAggregator
import com.opencsv.validators.RowValidatorAggregator

/**
* Helper class used to parse information from csv files using the column names
Expand Down Expand Up @@ -152,11 +156,23 @@ class CsvParser {
quoteChar = args.quoteChar ?: '"'
}

if (escapeChar != null) {
return new CSVReader(reader, separator, quoteChar, escapeChar, skipLines)
} else {
return new CSVReader(reader, separator, quoteChar, skipLines)
if (escapeChar == null) {
escapeChar = ICSVParser.DEFAULT_ESCAPE_CHARACTER
}
CSVParser parser = new CSVParser(separator, quoteChar, escapeChar,
ICSVParser.DEFAULT_STRICT_QUOTES,
ICSVParser.DEFAULT_IGNORE_LEADING_WHITESPACE,
ICSVParser.DEFAULT_IGNORE_QUOTATIONS,
ICSVParser.DEFAULT_NULL_FIELD_INDICATOR,
Locale.getDefault())
return new CSVReader(reader, skipLines, parser,
CSVReader.DEFAULT_KEEP_CR,
CSVReader.DEFAULT_VERIFY_READER,
CSVReader.DEFAULT_MULTILINE_LIMIT,
Locale.getDefault(),
new LineValidatorAggregator(),
new RowValidatorAggregator(),
null)
}

/**
Expand Down