mhaemmerle / excel-to-json

Opinionated Excel to JSON converter where nested structures can be defined on different worksheets
http://mhaemmerle.github.io/excel-to-json/
Apache License 2.0
102 stars 25 forks source link

float values are generated with unexpected precision #26

Closed nhmtns closed 9 years ago

nhmtns commented 9 years ago

Currently float values in cells are generated with unexpected finer precision. For example, type any float value more than one decimal position (try two or three) and notice values generated in the json file are not exactly the original excel cell values but have much more decimal positions (finer precision).

I narrowed the issue to this line of code in the "converter.clj" file:

(if-let [result (re-find #"^([-+]?[0-9]+)(.[0-9]+)?$" value)](if %28last result%29 %28. Float parseFloat value%29 %28. Integer parseInt value%29)

I hacked above to: (if-let [result (re-find #"^([-+]?[0-9]+)(.[0-9]+)?$" value)](if %28last result%29 value value)

and all my float values are now generated correctly as expected.

eproxus commented 9 years ago

I'm sorry, but I don't see a difference between the two expressions. Did you pass the wrong line?