How to specify thousand separator with data

My Excel spread uses apostrophes to separate thousands and even worse it uses" ’ " instead of straight apostroph e.g. 1’000. Is there a way to specify this in Because when I import data it interprets 1’000 as 1\x92000.

Excel Data comes in the form of:

then I use“filepath.csv”, delim =“;”, dateformat= “”, normalizenames= true, DataFrame);

println(df) shows the Amount as String7 which prohibits me from doing any calculation with the data.


Welcome to the community! Can you post an example of the data that you’re trying to read so that others can easily copy/paste it as they attempt to help? Thanks!

There is not:

As a workaround, you can just remove the separator and parse the resulting string as a number. In the DataFrames.jl mini-language:

julia> transform!(df, :Amount =>  ByRow(str -> parse(Int, replace(str, '’' => ""))) => :Amount)
3×3 DataFrame
 Row │ Amount  Date        Time
     │ Int64   Date        String15
   1 │   1000  2022-01-10  13:22:17
   2 │   6000  2022-01-10  13:20:12
   3 │   3000  2022-01-10  13:23:08

or more simply

df.Amount = parse.(Int, replace.(df.Amount, '’' => ""))
1 Like

You should also be able to use read the file into a string, delete the delimiter, and do on an in-memory buffer (IOBuffer):

s = filter(!=('’'), read("filepath.csv", String)), delim=';', ....)

Thanks a lot for the suggestions.

@drvi just added support for this in the Parsers.jl package, so now we just need to plumb support for this in the CSV.jl package if someone wanted a pretty easy first issue to try out.