Data are read from excel xls file in which some numbers are stored as text and comma-seperated.
Dataframe sreenshot (read using ExcelFiles.jl):
I have tried function tryparse or parse, but it does not work as expected. Failed example in short here:
The question is: how to convert these comma-seperated texted numbers to normal numbers in Julia?
julia> parse(Float64, replace("1,000", "," => "."))
Thanks. It would work.
However, given the background of dealing with DataFrame read from Excel, I am not sure if there is any conventional trick to do this conversion?
There is a reason you are not saving the file as CSV, and reading it to a DataFrame with
Also, are you sure the comma is not being used to separate thousands? The solution given consider it is separating the fractional part, but considering the magnitude of the values (and the fact it is always three digits after the comma) involved it seems like it using the comma to separate thousands not the fractional part.
In case the comma is used to separate thousands you need to write
parse(Float64, replace("1,000", "," => "")) instead...
We have a batch of legacy xls files with several sheets.
Thanks. Replace and parse works!