q
q copied to clipboard
Integer output Scientific Notation
Hi: I have a column like 1000247787770076600034, and it output 1.00024778777e+21. How can I output the column as a string? Thank you.
Sorry that i don't have a proper solution for this - q supports integers up to 2^63 (similar to sqlite). Numbers higher than that are treated as doubles, and hence are displayed as such.
The master branch's latest contains an additional parameter --as-text, which makes q treat all fields as text - You can download and use this version with this parameter and see if it can help with your specific use case.
If anyone has any good idea on how to handle this better, it'd be great.
--as-text helps me,thank you.
Another way is to use -f parameter, example:
$ cat example.txt
24161010220097026928 603.43
42422402656113053824 327.95
64951386600336086457 647.55
36495639647086452073 119.20
47026818054162399542 748.17
$ q -d $'\t' -f 1="%d" "select * from example.txt where c2>500"
24161010220097028096 603.43
64951386600336089088 647.55
47026818054162399232 748.17
But when I replace %d with %s, the result becomes:
2.41610102201e+19 603.43
6.49513866003e+19 647.55
4.70268180542e+19 748.17
I writed some test code in python:
print("%d" % 24161010220097026928)
print("%s" % 24161010220097026928)
Both of the lines output 24161010220097026928, but why it's different in q?