Egga Hartung
Egga Hartung

Reputation: 1091

Super CSV and Grouping Separators

We are trying to read a file that contains numbers in the following format: 123.456,78 (according to Wikipedia this is usual for some countries - e.g. Germany).

Super CSV is configured to parse the column as BigDecimal: new ParseBigDecimal(new DecimalFormatSymbols(GERMANY)).

That works well for numbers below 1k, but the grouping separator is not handled properly: '1.999,00' could not be parsed as a BigDecimal.

I've seen that it is possible to write a custom cell processor, but perhaps someone knows if there is an easier way or if this is a known bug in Super CSV.

UPDATE:

Super CSV has integrated that feature and released it with version 2.2.0. It will work for all grouping separators that are supplied via the DecimalFormatSymbols parameter.

Upvotes: 2

Views: 338

Answers (1)

James Bassett
James Bassett

Reputation: 9868

ParseBigDecimal (prior to 2.2.0) only uses the decimal separator from the supplied DecimalFormatSymbols (not the grouping separator). It's not a bug, just a limitation of the current implementation.

You can chain a StrReplace before the ParseBigDecimal (i.e. replace "." with "") and that should fix your problem (quickly).

I think that ParseBigDecimal should actually do this for you. UPDATE: And so does it since version 2.2.0.

Like you said, you can always write your own cell processor too :)

Upvotes: 2

Related Questions