Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for parse #51

Closed
CNOT opened this issue Aug 29, 2019 · 1 comment
Closed

support for parse #51

CNOT opened this issue Aug 29, 2019 · 1 comment

Comments

@CNOT
Copy link

CNOT commented Aug 29, 2019

It would be nice if parse knew how to handle Measurement type numbers.
Something on the following lines, might work:

import Base.parse
function parse(::Type{Measurement}, s::AbstractString)
   n = parse.(Float64,split(s,"±"))
   return n[1]±n[2]
end

This is handy when you have Measurement type data produced and stored as a string, for example in a CSV file.

@giordano
Copy link
Member

giordano commented Aug 29, 2019

It already does: https://juliaphysics.github.io/Measurements.jl/stable/examples/#Measurements-from-Strings-1

julia> using Measurements

julia> parse(Measurement{Float64}, "4 ± 1.3")
4.0 ± 1.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants