On Mon, Oct 18, 2010 at 3:53 AM, Jack Su [email protected] wrote:
when humans look at a string, they will know whether it is a date, a
float, a percentage, or a currency, or simply a string.
for example, when you see, 3,232, you will know it is meant to be a
While true, what sort of number? Is it “three point two three two”, or
“three thousand two hundred thirty 3”?
(Germany uses “.” to format large numbers into three digit chunks,
while the UK and US use the “,”. Floats use the “,” in Germany, while
the US and UK use the “.”.)
The type of data we see gets interpreted depending on context. In the
us a 2x4 has different dimensions than in almost every other nation in
So, you are already stumbling into localization issues, which can be
compounded by standards, the use of SI units vs Imperial, vs
colloquial units, and so on, and so forth.
Parsing your data, number, e&. data with the help of a localization
library would get you quite a ways, already.
I wonder if there is easy way in ruby to figure out the data type for a
string. I guess I could let the string go through a list of the regular
expression – but if I have a lot of strings to process, it is likely to
It also breaks if you get data in formats that you didn’t anticipate.
And I don’t have a good solution for this, apart from forcing
particular data entry, but then you already know which field you get
contains which datatype.
Though the folk I have met,
(Ah, how soon!) they forget
When I’ve moved on to some other place,
There may be one or two,
When I’ve played and passed through,
Who’ll remember my song or my face.