How to parse string with non-US number format?

How to convert the string "132.993,00" to the floating point value 132993.00? Are the internationalization or locale packages in Julia that handle country-specific number formats?

Base.parse doesn’t contain options to parse non-US number formats.

You can do this with Parsers.jl using a custom Parsers.Options, like:

julia> using Parsers

julia> opts = Parsers.Options(; decimal=',', groupmark='.')
Parsers.Options(Parsers.Flags(spacedelim=false, tabdelim=false, stripquoted=false, stripwhitespace=false, checkquoted=true, checksentinel=false, checkdelim=true, ignorerepeated=false, ignoreemptylines=false), 0x2c, Parsers.Token(0x22), Parsers.Token(0x22), 0x22, Parsers.Token[], Parsers.Token(0x2c), Parsers.Token(""), nothing, nothing, nothing, 0x2e)

julia> Parsers.parse(Float64,  "132.993,00", opts)
132993.0
2 Likes