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

Columns with missing data are filled with stale data using CSV.Rows #903

Closed
Mrbigmatt opened this issue Sep 15, 2021 · 1 comment · Fixed by #904
Closed

Columns with missing data are filled with stale data using CSV.Rows #903

Mrbigmatt opened this issue Sep 15, 2021 · 1 comment · Fixed by #904

Comments

@Mrbigmatt
Copy link

Mrbigmatt commented Sep 15, 2021

When importing the attached file with CSV.Rows and iterating through the rows, the column with missing data is filled with the previous row's data. CSV.File seems to import this file correctly. This is with CSV.jl 0.9.2.

test.csv

quinnj added a commit that referenced this issue Sep 15, 2021
Fixes #903. The issue here is a consequence of the big internal
refactoring that happened for the 0.9 release. Part of the refactoring
is that `parserow` doesn't explicitly set a column's value to `missing`
if a sentinel value is detected while parsing. This is because when a
column is allocated, it's allocated with "all missing" values set, so it
_should_ already be set to missing. This doesn't hold up, however, for
`CSV.Rows`, where we only allocate a single element "column" vector for
each column and reuse it when iterating rows. The solution, therefore,
is to "reset" the column vectors before each call to `parserow` to
ensure the column values are set to missing in case a sentinel value is
detected while parsing.
@quinnj
Copy link
Member

quinnj commented Sep 15, 2021

Thanks for reporting! Unfortunate bug from a recent refactoring; fix is up: #904.

quinnj added a commit that referenced this issue Sep 15, 2021
Fixes #903. The issue here is a consequence of the big internal
refactoring that happened for the 0.9 release. Part of the refactoring
is that `parserow` doesn't explicitly set a column's value to `missing`
if a sentinel value is detected while parsing. This is because when a
column is allocated, it's allocated with "all missing" values set, so it
_should_ already be set to missing. This doesn't hold up, however, for
`CSV.Rows`, where we only allocate a single element "column" vector for
each column and reuse it when iterating rows. The solution, therefore,
is to "reset" the column vectors before each call to `parserow` to
ensure the column values are set to missing in case a sentinel value is
detected while parsing.
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