Le lundi 01 décembre 2014 à 03:50 -0800, paul analyst a écrit :
> Some times in "Char" data is number like 1.4e26 below
> How to process such data? sort, etc., ...
>
> julia> data=readcsv("data.txt")
> 6x1 Array{Any,2}:
> "146cd6a978544b0168fb11de000"
> "148b7f63e9e2222377c9b364000"
> "148b7f63e9e2222377c9b364000"
> "148ee93eb7c77ef0d249b5d2800"
> 1.4e26
> "148ce93eb7c77ef0a249b5d2800"
This does not sound like a very useful behavior to have by default,
though this is documented:
Base.readdlm(source, delim::Char, eol::Char; options...)
If all data is numeric, the result will be a numeric array. If some
elements cannot be parsed as numbers, a cell array of numbers and
strings is returned.
Any reason why readdlm() does not return an array of strings if one
element cannot be parsed as a number? Anyway if you're going to have to
fix the string elements, you can as well convert all the array to
numbers during that step.
In the case at hand, clearly most of the entries are strings; the fact
that one of them can be parsed as a number does not appear to justify
making this exception.
Should an issue be filed?
Regards
> julia> sort(data)
> ERROR: `sort` has no method matching sort(::Array{Any,2})
>
> Paul
>