pkiraly/metadata-qa-api

Dots are converted to commas in output

Opened this issue · 3 comments

Hi @pkiraly ,

I ran into a weird error. Consider the test case you wrote for my library: https://github.com/viaacode/metadata-quality-assessment/blob/mqa-0.8/src/test/java/be/meemoo/CalculatorTest.java#L81
This file is part of a branch that aligns with your 8.0 beta on sonatype.
The unittests fail because the output uses commas for CSV doubles, while as you can see, the expected output contains dots. It also seems to add a trailing column. Any idea what's causing this?

org.junit.ComparisonFailure: expected:<[1.0,1.0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
0.5,1.0,1,1,1,1,0,1,1,0,0,0,1,0,1,0,0,0
0.6875,1.0,1,1,1,1,0,1,1,1,0,0,1,0,1,0,1,1
...]
> but was:<["1,0","1,0",1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
"0,5","1,0",1,1,1,1,0,1,1,0,0,0,1,0,1,0,0,0,
"0,6875","1,0",1,1,1,1,0,1,1,1,0,0,1,0,1,0,1,1,
... ]

@mielvds At first sight it seems the problem is something with the OS's Locale settings. I should check the code if is there anything in the Java functions it call, if there is anything which might depend on locale settings. Which Java version do you use?

I was thinking the same thing! It's java 11, probably osx is doing something funny. I'll check it out tomorrow

@pkiraly the issue is the use of String.format here: https://github.com/pkiraly/metadata-qa-api/blob/main/src/main/java/de/gwdg/metadataqa/api/util/Converter.java#L97

It's probably better to include the locale in that and similar calls: String.format(Locale.US, "%.6f", value);. That said, the best thing would probably to leave such conversions to a serialization library for CSV and JSON.