Skip to content

Tabs are not trimmed when trim_ws = TRUE #767

@mirkhosro

Description

@mirkhosro

When using read_csv to read a CSV file that contains tabs on its rows, the trim_ws argument does not seem to have any effect. The tab characters do not get stripped anyway.
Take this CSV file for example

X,Y
x1,y1
x2	,y2
x3,y3	
x4,y4

There is a tab after x2 and after y3 (not visible). And the code below demonstrates the issue

> data <- read_csv("test.csv", trim_ws = TRUE, col_types = "cc")
> data[, 1]
# A tibble: 4 x 1
       X
   <chr>
1     x1
2 "x2\t"
3     x3
4     x4
> data[, 2]
# A tibble: 4 x 1
       Y
   <chr>
1     y1
2     y2
3 "y3\t"
4     y4

As you can see the tab characters are there and not trimmed.
I'm running the code using R 3.3.3 and readr 1.1.1. on macOS High Sierra.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugan unexpected problem or unintended behavior

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions