turbomanage / storm-gen

Simple ORM for Android SQLite
Apache License 2.0
83 stars 15 forks source link

Issue exporting double values to CSV #44

Closed asafge closed 9 years ago

asafge commented 9 years ago

Hey, I have a double field that contains some small numbers, like 0.0, 0.85, etc. When exporting the table to CSV, I get hex values like 3feb333333333333 instead of the real string representation. I noticed that DoubleConverter doesn't use Double.toString(sqlValue) directly (which would have worked in my case).

I'm I doing something wrong or is this an issue?

turbomanage commented 9 years ago

This is intentional, as String representations do not preserve the exact value when converting from String back to double.

asafge commented 9 years ago

OK I see. Is there a anything I can do in case I want my output to be readable, instead of accurate? Like some kind of class I can override? I think that it might be a good option to include, CSVs are sometimes used directly by developers, not by code.

turbomanage commented 9 years ago

Hi Asaf, easiest thing would be to supply your own com.turbomanage.storm.types.DoubleConverter and build from source (mvn package install). It's possible that you may be able to supply your own DoubleConverter without replacing the built-in one by just copying the existing DoubleConverter class to your own package and modifying the toString / fromString methods, but I haven't tried this.

Alternatively, you could write a converter script that would run after the fact, read the CSV dump with hex values, and write it back out as decimal.

On Mon, Mar 23, 2015 at 8:56 AM, Asaf Geva notifications@github.com wrote:

OK I see. Is there a anything I can do in case I want my output to be readable, instead of accurate? Like some kind of class I can override? I think that it might be a good option to include, CSVs are sometimes used directly by developers, not by code.

— Reply to this email directly or view it on GitHub https://github.com/turbomanage/storm-gen/issues/44#issuecomment-85036122 .