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

Dots are converted to commas in output #81

Open
mielvds opened this issue Oct 6, 2021 · 3 comments
Open

Dots are converted to commas in output #81

mielvds opened this issue Oct 6, 2021 · 3 comments

Comments

@mielvds
Copy link
Contributor

mielvds commented Oct 6, 2021

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,
... ]
@pkiraly
Copy link
Owner

pkiraly commented Oct 6, 2021

@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?

@mielvds
Copy link
Contributor Author

mielvds commented Oct 6, 2021

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

@mielvds
Copy link
Contributor Author

mielvds commented Oct 20, 2021

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants