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

Incorrect parsing of floats in corner cases #714

Closed
bkamins opened this issue Aug 8, 2020 · 8 comments · Fixed by JuliaData/Parsers.jl#61
Closed

Incorrect parsing of floats in corner cases #714

bkamins opened this issue Aug 8, 2020 · 8 comments · Fixed by JuliaData/Parsers.jl#61
Labels

Comments

@bkamins
Copy link
Member

bkamins commented Aug 8, 2020

Here is an example:

julia> CSV.read(IOBuffer("x\n-1670."), DataFrame)
1×1 DataFrame
│ Row │ x          │
│     │ Float64    │
├─────┼────────────┤
│ 1   │ 1.84467e19 │
@bkamins bkamins added the bug label Aug 8, 2020
@nathanrboyer
Copy link

Here are examples of other numbers with the same issue.

Original CSV File: MiddlePrincipalStresses
FIltered CSV FIle: ElementsReadWrong

ElementsReadWrong.txt
MiddlePrincipalStress.txt

@bkamins
Copy link
Member Author

bkamins commented Aug 8, 2020

I have not checked in detail, but it seems that it gets wrong if the number is negative and has a trailing . - is this correct?

@quinnj
Copy link
Member

quinnj commented Aug 8, 2020

I think I have a fix for this; writing tests now

@quinnj
Copy link
Member

quinnj commented Aug 8, 2020

Yes, I believe those are the only cases affected

quinnj added a commit to JuliaData/Parsers.jl that referenced this issue Aug 8, 2020
Because we're using a UInt64, our final number was getting messed up
because we were applying the `-` to the UInt64 before converting to our
float number. Fixed JuliaData/CSV.jl#714
@quinnj
Copy link
Member

quinnj commented Aug 8, 2020

Fix up: JuliaData/Parsers.jl#61

quinnj added a commit to JuliaData/Parsers.jl that referenced this issue Aug 8, 2020
Because we're using a UInt64, our final number was getting messed up
because we were applying the `-` to the UInt64 before converting to our
float number. Fixed JuliaData/CSV.jl#714
@nathanrboyer
Copy link

My numerical data are now being read as Strings.

@quinnj
Copy link
Member

quinnj commented Aug 8, 2020

I see that as well; investigating.

@quinnj
Copy link
Member

quinnj commented Aug 8, 2020

Sorry about the hassle; the previous fix ended up only working for negative + trailing decimal; I have JuliaData/Parsers.jl#64 which also fixes the non-negative case.

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

Successfully merging a pull request may close this issue.

3 participants