Skip to content

General strategies for hard-to-parse files #1450

Open
@hadley

Description

@hadley

Also from R4DS:


Sometimes it's easier to diagnose problems if you just read in all the columns as character vectors:

#| eval: false

df <- read_csv(
  "challenge.csv",
  col_types = cols(.default = col_character())
)

If you're having major parsing problems, sometimes it's easier to just read into a character vector of lines with read_lines():

#| eval: false

df <- read_lines("challenge.csv")

Then you can use dplyr and the tools you'll learn in @sec-strings to figure out what's going wrong.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions