Skip to content

count_fields does not interpret single line string wrapped with I() as literal data #1581

@mrainers

Description

@mrainers

The manual of count_fields {readr} decribe the file parameter as following:

To be recognised as literal data, the input must be either wrapped with I(), be a string containing at least one new line, or be a vector containing at least one string with a new line.

However, wrapping the string with I() doesn't seem to have any effekt. If file is a single string it is interpreted as a file name even when wrapped with I() instead of literal data.

data <- c('"foo","bar","baz"')
count_fields(I(data), tokenizer = tokenizer_csv())

Error: '"foo","bar","baz"' does not exist in current working directory 

Expected result: 3

Workaround: temporarly attach a new line.

data <- c('"foo","bar","baz"')
count_fields(paste0(data, "\n"), tokenizer = tokenizer_csv())

readr version: 2.1.5

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