Skip to content

Lines read and skip lines use different evaluation in vroom_lines #549

@pepijn-devries

Description

@pepijn-devries

Originally reported here at readr:

tidyverse/readr#1500

After some more digging I have traced this issue back to vroom where the same problem occurs when skipping lines when there is a Line Feed (\n) followed by a Carriage Return (\r). In the reprex below skipping 2 lines results in unexpected behaviour, I think it is skipping the lines, but then stops reading the remainder. If you skip 3 lines, all seems well again:

library(vroom)

text <- "001\n002\n\r003\n004"

vroom_lines(I(text), skip = 0)
#> [1] "001"   "002"   "\r003" "004"
vroom_lines(I(text), skip = 1)
#> [1] "002"   "\r003" "004"
vroom_lines(I(text), skip = 2)
#> [1] ""
vroom_lines(I(text), skip = 3)
#> [1] "003" "004"
vroom_lines(I(text), skip = 4)
#> [1] "004"

Created on 2025-03-02 with reprex v2.0.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions