q
q copied to clipboard
Number rounding destroying data
When doing a select on a CSV that has a numeric column, "3873194.8699999987" gets rounded to "3873194.87". Please prevent this or introduce a parameter to control it. Thanks!
Hi @dkvasnicka
This is indeed an issue, and requires adding full support for decimal types.
I already have an intermediate temporary version which allows to force all column types to strings. This has been helpful in one related use case. However, it won't be helpful in your case, unless you're writing the output fields without any computation whatsoever.
If you want it, I'd be glad to send it to you. Just drop me a line over email.
I'm working on abstracting the decimal values issue away (sqlite does not have a real notion of a decimal, so it needs to be handled by q).
Harel
Hi and thanks for the prompt response,
In this case I was writing the decimal fields without any computation but other whole-number fields were involved in some computation - so coercing all stuff into string isn't an option.
For now I've solved this using a custom script so this bug isn't a blocker for me.
@harelba I having a similar issue, a columns with code numbers, some of the numbers start with leading '0', but when i make a query, the command detect that the column is a number, and outputs the number removing the leading 0, what it's incorrect, becuase the code must have all the digits. How i can force 'q' to read all the columns or some of them as strings?
I think this is in fact related to ticket https://github.com/harelba/q/issues/171. The solution is to use at least version 1.6.0
and providing the --as-text
option.
Thanks @bitti , it worked!