Skip to content
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

The quote argument in read_tsv might not work correctly #1254

Closed
jpquast opened this issue Jul 30, 2021 · 1 comment
Closed

The quote argument in read_tsv might not work correctly #1254

jpquast opened this issue Jul 30, 2021 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@jpquast
Copy link

jpquast commented Jul 30, 2021

I am trying to read a text file into R, that sometimes has quoted names in a rows and it only contains one column. This can look like the following:

first row
second "row"
"third" row
"fourth row"

If I try reading this file using the read_tsv() function (because rows never contain tabs, but might contain commas), it reads it in the following way:

read_tsv("my_file.tsv", 
col_names = FALSE, 
show_col_types = FALSE, 
progress = FALSE, 
quote = "")
# A tibble: 4 x 1
  X1              
  <chr>           
1 "first row"     
2 "second \"row\""
3 "third row"     
4 "fourth row"  

What I would expect from the argument quote = "" is however, that it would keep and escape all the quotes.
If I use the function read_delim() this is done correctly:

read_delim("my_file.tsv", 
delim = "\t", 
col_names = FALSE, 
show_col_types = FALSE, 
progress = FALSE, 
quote = "")
  X1               
  <chr>            
1 "first row"      
2 "second \"row\"" 
3 "\"third\" row"  
4 "\"fourth row\" "

It seems to me that the quote argument does not do anything when used in the read_tsv() function as compared to the read_delim() function. Maybe I made a mistake here and this is expected, but to me this does not seem as it is intended.
Help would be greatly appreciated!

@jimhester jimhester added the bug an unexpected problem or unintended behavior label Jul 30, 2021
@jimhester
Copy link
Collaborator

Thank you for opening the issue with a reproducible example!

This was a bug in read_tsv() with readr 2.0.0, it was not correctly passing the quote argument down.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants