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

Not consistent decimal separator in JNI calls can give strange results #8

Open
WojciechMazur opened this issue Nov 10, 2021 · 1 comment

Comments

@WojciechMazur
Copy link

In case if system locale is using , (comma) for decimal separator JVM would not be able to correctly parse measurements received from JNI call with CSV string. It can be fixed by setting en-us locale at beginning of energy_stat_csv_string and restoring it to the previous one before returning from a call, but maybe there is a better way to fix that issue.

@aservet1
Copy link
Owner

aservet1 commented Nov 11, 2021

I made a change where you can set the CSV delimiter to whatever char type you'd like. It's my understanding that European CSV files are commonly ; (semicolon) delimited for the comma-float reason? Correct me if I'm wrong.

This makes it so any invocation of something that uses the CSV format (return from JNI, .csv() methods for the energy sample objects, AsyncEnergyMonitor.writeFileCSV(), etc) will delimit by that char. So you can set it to ; or \t or whatever single character you want.

Just write EnergyMonitor.setCSVDelimiter(';') at any point during your code before a call that will use it and you're set.

The default CSV delimiter remains a comma in the event that this method is never called.

This doesn't feel ideal to be honest, but it seems like consistent CSV standards with regard to comma-floats is an open problem without a straightforward solution. Let me know if this doesn't work for your case or you think something else would work better.

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