Skip to content

Use OBSV8 observation count when reading XPORT files - #399

Merged
evanmiller merged 2 commits into
WizardMac:devfrom
hadley:xport-obsv8-count
Oct 11, 2026
Merged

evanmiller merged 2 commits into
WizardMac:devfrom
hadley:xport-obsv8-count

Conversation

@hadley

@hadley hadley commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

馃 Written by AI, reviewed by me 馃

Trailing rows that are entirely blank (e.g. a single character column ending in empty strings) are currently dropped because they're indistinguishable from the space padding at the end of the final 80-byte record. V8 files record the observation count in the OBSV8 header, which ReadStat writes but never reads, so this uses it to read exactly that many rows. V5 files, and V8 files with a blank or zero count, keep the existing heuristic.

Reported in tidyverse/haven#754.

@hadley
hadley marked this pull request as draft October 10, 2026 18:07
Previously, trailing rows consisting entirely of blanks were discarded as end-of-file padding. For V8 files, the observation count in the `OBSV8` header is now used to read exactly that many rows. Files without a usable count (V5, or a blank/zero count) fall back to the existing heuristic.
@hadley
hadley force-pushed the xport-obsv8-count branch from 1dce133 to ee2fa19 Compare October 10, 2026 18:10
@hadley
hadley changed the base branch from master to dev October 10, 2026 18:10
@hadley
hadley marked this pull request as ready for review October 10, 2026 18:18
@evanmiller
evanmiller merged commit b05b645 into WizardMac:dev Oct 11, 2026
12 checks passed
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 this pull request may close these issues.

2 participants