ConfParser.jl icon indicating copy to clipboard operation
ConfParser.jl copied to clipboard

Float values are not parsed as floats

Open dburov190 opened this issue 5 years ago • 5 comments

The parser retrieves values like "1e-3" as Strings rather than Float64 variables, at least in the case of "INI" files.

dburov190 avatar Jul 01 '19 22:07 dburov190

I think everything is parsed as String. In general guessing the proper type and parsing it is quite complicated (and this package is very simple). For now you'll have to parse your parameters yourself (parse(Float64, x)).

jonathanBieler avatar Jul 02 '19 09:07 jonathanBieler

You're right about everything being parsed as a string, I didn't notice that... and yes, parsing is quite involved, but thanks to the standard parse function you mentioned it's not that hard. For example, is it possible to add an optional default (which would be helpful in and out of itself, in case there's no key you're trying to retrieve) that would be used to infer the type? something like parse(typeof(default), x)?

dburov190 avatar Jul 02 '19 17:07 dburov190

Isn't this what retrieve(s::ConfParse, block::String, key::String, t::Type) is for? It retrieves the key then parses it as a Float32?

pixel27 avatar Jul 14 '19 12:07 pixel27

@pixel27 Maybe it is, but I'd have no idea because it's not documented, not even in the simplest "examples" way... see #21 (:

dburov190 avatar Jul 15 '19 01:07 dburov190

I'll try to setup the documentation.

jonathanBieler avatar Jul 15 '19 09:07 jonathanBieler