New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

different quoting behavior, depending on whitespace #668

Closed
ijlyttle opened this Issue May 6, 2017 · 3 comments

Comments

Projects
None yet
3 participants
@ijlyttle
Contributor

ijlyttle commented May 6, 2017

Sometimes I will write out a small csv by hand - by habit I will put a space after a comma:

"foo", "bar"
"a", "b"

When I read_csv() this, it parses inconsistently.

However, if I take out the whitespace, it parses as I expect:

"foo","bar"
"a","b"

Reprex:

library("readr")

read_csv('"foo","bar"\n"a","b"\n')
#> # A tibble: 1 × 2
#>     foo   bar
#>   <chr> <chr>
#> 1     a     b

read_csv('"foo", "bar"\n"a", "b"\n')
#> # A tibble: 1 × 2
#>     foo `"bar"`
#>   <chr>   <chr>
#> 1     a     "b"

Does this rise to the level of bug? Also, may be similar to #238.

@jennybc

This comment has been minimized.

Member

jennybc commented Aug 26, 2017

I'm running up against this too. It's especially damaging if you're using the quotes to protect embedded commas. Also: something is off with the printing of the problems?

library(readr)
read.csv(text = 'x,y\n1,\"hi,there\"\n3,4')
#>   x        y
#> 1 1 hi,there
#> 2 3        4
read_csv('x,y\n1,\"hi,there\"\n3,4')
#> # A tibble: 2 x 2
#>       x        y
#>   <int>    <chr>
#> 1     1 hi,there
#> 2     3        4
  
read.csv(text = 'x,y\n1, \"hi,there\"\n3,4')
#>   x         y
#> 1 1  hi,there
#> 2 3         4
read_csv('x,y\n1, \"hi,there\"\n3,4')
#> Warning in rbind(names(probs), probs_f): number of columns of result is not
#> a multiple of vector length (arg 2)
#> Warning: 1 parsing failure.
#> row # A tibble: 1 x 5 col     row   col  expected    actual         file expected   <int> <chr>     <chr>     <chr>        <chr> actual 1     1  <NA> 2 columns 3 columns literal data file # A tibble: 1 x 5
#> # A tibble: 2 x 2
#>       x      y
#>   <int>  <chr>
#> 1     1 "\"hi"
#> 2     3      4

@jimhester jimhester added the bug label Dec 7, 2017

@jimhester jimhester closed this in dd194ef Dec 11, 2017

@ijlyttle

This comment has been minimized.

Contributor

ijlyttle commented Dec 11, 2017

@jimhester Thanks!

@lock

This comment has been minimized.

lock bot commented Sep 25, 2018

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Sep 25, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.