- Feb 8, 2004
- 12,604
- 15
- 81
I have this government created excel sheet of food nutrition:
Most of it is decimals however some cell values are "Tr" and "N". Tr means trace amounts and N means no data. The problem is I cant put those values into a column which has a numeric type, its either a number or null. I thought up two solutions, maybe theres a better one but I dunno. Would be good to hear what you guys think:
Solution 1: Just use "character varying" type for all the currently numeric columns. Im leaning towards this because the results get turned into a JSON string anyway and then the JavaScript on the client side does what it wants with them.
Solution 2: Have a specific decimal number to represent trace amounts, something like "0.0001". This seems a bit hackey and crap tbh but it could work.
Up until now ive just replaced all "Tr" values with "N" and treated it as null but I dont think thats a good long term plan because a trace amount is still a trace amount and should be represented as such.

Most of it is decimals however some cell values are "Tr" and "N". Tr means trace amounts and N means no data. The problem is I cant put those values into a column which has a numeric type, its either a number or null. I thought up two solutions, maybe theres a better one but I dunno. Would be good to hear what you guys think:
Solution 1: Just use "character varying" type for all the currently numeric columns. Im leaning towards this because the results get turned into a JSON string anyway and then the JavaScript on the client side does what it wants with them.
Solution 2: Have a specific decimal number to represent trace amounts, something like "0.0001". This seems a bit hackey and crap tbh but it could work.
Up until now ive just replaced all "Tr" values with "N" and treated it as null but I dont think thats a good long term plan because a trace amount is still a trace amount and should be represented as such.