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

read_lines() warning message and the problems() function #1501

Open
mrhumanzee opened this issue Jul 1, 2023 · 4 comments
Open

read_lines() warning message and the problems() function #1501

mrhumanzee opened this issue Jul 1, 2023 · 4 comments
Labels
bug an unexpected problem or unintended behavior read 📖

Comments

@mrhumanzee
Copy link

I'm working with the binary object casetable_bin. When I tried to parse this object into a string vector using the command casetable_lines <- read_lines(casetable_bin), I received the following warning message:

One or more parsing issues, call problems() on your data frame for details, e.g.:
dat <- vroom(...)
problems(dat)

However, running the command readr::problems(casetable_lines) returns nothing. Furthermore, running the command attributes(casetable_lines) returns only the NULL value. Where does readr store the problems it detects in objects?

@hadley hadley added the reprex needs a minimal reproducible example label Jul 31, 2023
@hadley
Copy link
Member

hadley commented Jul 31, 2023

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you! If you've never heard of a reprex before, start by reading about the reprex package, including the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.

@mrhumanzee
Copy link
Author

Can you please provide a minimal reprex (reproducible example)? The goal of a reprex is to make it as easy as possible for me to recreate your problem so that I can fix it: please help me help you! If you've never heard of a reprex before, start by reading about the reprex package, including the advice further down the page. Please make sure your reprex is created with the reprex package as it gives nicely formatted output and avoids a number of common pitfalls.

# Load 'readr'
library(readr)

# Create an empty vector to store each unique ASCII character
ascii_vector <- raw(128)

# Fill the vector with ASCII characters using a loop
for (i in 0:127) {
  ascii_vector[i + 1] <- as.raw(i)
}

# Print the vector
print(ascii_vector)
#>   [1] 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 14 15 16 17 18
#>  [26] 19 1a 1b 1c 1d 1e 1f 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 31
#>  [51] 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f 40 41 42 43 44 45 46 47 48 49 4a
#>  [76] 4b 4c 4d 4e 4f 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f 60 61 62 63
#> [101] 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f 70 71 72 73 74 75 76 77 78 79 7a 7b 7c
#> [126] 7d 7e 7f


# The function 'read_lines()' returns a warning message: 
read_lines(ascii_vector)
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
#> [1] ""


# Calling the function 'problems()' returns nothing
readr::problems(ascii_vector) 
attributes(ascii_vector) 
#> NULL
Ā
#> Error in eval(expr, envir, enclos): object 'Ā' not found

Created on 2023-07-31 with reprex v2.0.2

Interestingly, when I run this code without reprex, I do not get Ā followed by #> Error in eval(expr, envir, enclos): object 'Ā' not found.

@hadley
Copy link
Member

hadley commented Jul 31, 2023

Thanks! Here's a somewhat more minimal reprex:

library(readr)

ascii_vector <- raw(128)
for (i in 0:127) {
  ascii_vector[i + 1] <- as.raw(i)
}

out <- read_lines(ascii_vector)
#> Warning: One or more parsing issues, call `problems()` on your data frame for details,
#> e.g.:
#>   dat <- vroom(...)
#>   problems(dat)
problems(out) 

Created on 2023-07-31 with reprex v2.0.2

@hadley hadley added bug an unexpected problem or unintended behavior read 📖 and removed reprex needs a minimal reproducible example labels Jul 31, 2023
@mrhumanzee
Copy link
Author

I forgot to store the output to read_lines() in my reprex, my bad! However, it appears the problem is demonstrated in the example you give.

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 read 📖
Projects
None yet
Development

No branches or pull requests

2 participants