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

CSV.File is corrupting missingstrings parameter #780

Closed
Am386DX-40 opened this issue Nov 19, 2020 · 1 comment · Fixed by JuliaData/Parsers.jl#73
Closed

CSV.File is corrupting missingstrings parameter #780

Am386DX-40 opened this issue Nov 19, 2020 · 1 comment · Fixed by JuliaData/Parsers.jl#73

Comments

@Am386DX-40
Copy link

Am386DX-40 commented Nov 19, 2020

using CSV

file = "test.csv"

missing_strings = ["-999", "NA"]
CSV.File(file; missingstrings=missing_strings)
@show missing_strings

shows:

missingstrings = ["-999", "NA", "true", "True", "TRUE", "1", "false", "False", "FALSE", "0"]
10-element Array{String,1}:
 "-999"
 "NA"
 "true"
 "True"
 "TRUE"
 "1"
 "false"
 "False"
 "FALSE"
 "0"

I would expect it to stay:

missing_strings = ["-999", "NA"]
2-element Array{String,1}:
 "-999"
 "NA"
Am386DX-40 pushed a commit to Am386DX-40/CSV.jl that referenced this issue Nov 19, 2020
quinnj added a commit to JuliaData/Parsers.jl that referenced this issue Nov 20, 2020
Fixes JuliaData/CSV.jl#780. The issue here is
Parsers.Options was assuming ownership of and modifying the input
`sentinel` if it was a `Vector{String}`. The fix is to make a copy
instead and then we can modify and use it to store references to other
strings as needed.
quinnj added a commit to JuliaData/Parsers.jl that referenced this issue Nov 20, 2020
Fixes JuliaData/CSV.jl#780. The issue here is
Parsers.Options was assuming ownership of and modifying the input
`sentinel` if it was a `Vector{String}`. The fix is to make a copy
instead and then we can modify and use it to store references to other
strings as needed.
@quinnj
Copy link
Member

quinnj commented Nov 20, 2020

Thanks for the report. This is actually a Parsers.jl issue, which is modifying the input missingstrings array. Fix is up there: JuliaData/Parsers.jl#73.

quinnj added a commit to JuliaData/Parsers.jl that referenced this issue Nov 20, 2020
Fixes JuliaData/CSV.jl#780. The issue here is
Parsers.Options was assuming ownership of and modifying the input
`sentinel` if it was a `Vector{String}`. The fix is to make a copy
instead and then we can modify and use it to store references to other
strings as needed.
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

Successfully merging a pull request may close this issue.

2 participants