uniVocity-parsers v2.8.0 Release Notes
Release Date: 2019-02-01 // about 5 years ago-
โจ Enhancements:
- ๐ Map column name to attribute #287: This is a big change. Basically you can now skip annotations altogether and manually define mappings from parsed columns to an object, including nested attributes.
Now you can call
getColumnMapper()
from:- any
*Routines
class any
*Bean*Processor
class (includingBeanWriterProcessor
) for writingmapper.attributeToIndex("name", 0); //name goes to the first column mapper.attributeToColumnName("name", "client_name"); .// same thing, but the first column has header "client_name"
๐ Nested classes are also supported, you can do stuff such as the following, where
name
is buried in an object structure (assume a class Purchase with a Buyer attribute, which in turn has a Contact attribute, where the name is located:mapper.methodToIndex("buyer.contact.name", 0); // use methods too. This assumes Contact has a `fullName(java.lang.String)` setter method: mapper.methodToColumnName("buyer.contact.fullName", String.class, "client_name"); // this maps getter and setter methods named `fullName` to column `client_name`. The getters or setters are used depending if you are writing to a file or reading from it. mapper.methodToColumnName("buyer.contact.fullName", "client_name");
You can also just give it a map:
Map<String, Integer> mappings = new HashMap<String, Integer>(); ... fill your map mapper.attributesToIndexes(mappings);
โ Contrived unit tests: https://github.com/uniVocity/univocity-parsers/blob/master/src/test/java/com/univocity/parsers/issues/github/Github_287.java
Other enhancements:
๐ Support CSV delimiters of more than one character #209: instead of using one character, delimiters now can be anything (e.g:
##
,:-p
etc).๐ Support creation of immutable objects #280: create instances of java beans with private constructors and no setter methods.
โก๏ธ Enable case-sensitive column header matching #283: You can now target files with columns such as
'A'
, 'a'
,' A '
and' a '
. Any existing code should not be affected. For example: if you useparserSettings.selectFields("a")
and the parsed header is' A '
, then' A '
will be selected as usual. This update allows one to useparserSettings.selectFields(" A ", "a")
when headers such as' A '
and'a'
are present (you can go wild here and target many different columns namedaaa
with different number of surrounding spaces or different character case combinations).๐ CsvParser beginParsing closes the stream #303: Introduced flag to prevent the parser from automatically closing the input:
parserSettings.setAutoClosingEnabled(false)
โ Add option on FixedWidthParserSettings to keep padding of parsed values #276: the
@FixedWidth
annotation now has akeepPading
property. This can also be set on theFixedWidthFields
, using methodskeepPadingOn(columns)
andstripPaddingFrom(columns)
.Introduce
UnescapedQuoteHandling.BACK_TO_DELIMITER
#259: if an unescaped quote is detected, the parser will re-process the parsed value and split the unescaped value into individual values after each delimiter found.๐ Bugfixes:
๐ An extra row with null returned #306
๐ Cannot determine column separator #305
๐ Wrong line ending detection when normalizeLineEndingsWithinQuotes = false #299
๐ Column selection makes @Validate annotation misbehave #296
๐ Fixed width parsing with look-ahead and non-contiguous field definitions #294
๐
CsvParser.parse
ignoresheaders
parser setting inprocessStarted
Processor's method #289