JuliaIO / ConfParser.jl

Julia package for parsing configuration files
Other
44 stars 17 forks source link

Float values are not parsed as floats #22

Open dburov190 opened 5 years ago

dburov190 commented 5 years ago

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

jonathanBieler commented 5 years ago

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)).

dburov190 commented 5 years ago

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)?

pixel27 commented 5 years ago

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?

dburov190 commented 5 years ago

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

jonathanBieler commented 5 years ago

I'll try to setup the documentation.