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

problems() not pulling up the exact text of a parsing failure #548

Closed
kendonB opened this Issue Nov 6, 2016 · 4 comments

Comments

3 participants
@kendonB

kendonB commented Nov 6, 2016

The example:

library(tidyverse)
x <- tribble(
  ~unit, ~value,
  "a"  ,    "1",
  "b"  ,     "(NA)")
write_tsv(x, path = "test.tsv")

Now try and parse with the incorrect NA specification (in the real application it's not obvious exactly what represents NA).

new_x <- read_tsv("test.tsv",
                  na = "",
                  col_types = cols(
                      unit = col_character(),
                      value = col_number()
                    ))
file.remove("test.tsv")

problems(new_x)
# A tibble: 1 × 4
#     row   col expected actual
#   <int> <chr>    <chr>  <chr>
# 1     2 value a number       

I would have expected this to come up:

# A tibble: 1 × 4
#   row     col expected actual
# <int>   <chr>    <chr>  <chr>
# 1   2   value a number   (NA) 

Is this the expected behavior?

@hadley hadley added bug read labels Dec 22, 2016

@hadley

This comment has been minimized.

Member

hadley commented Dec 22, 2016

Simpler reprex:

problems(read_tsv("x\n1\nx", na = "", col_types = "n"))

This is ok:

problems(read_tsv("x\n1\nx", na = "", col_types = "d"))

So probably a buglet in the number collector.

@hadley hadley added collector and removed read labels Dec 22, 2016

jimhester added a commit to jimhester/readr that referenced this issue Jan 26, 2017

jimhester added a commit to jimhester/readr that referenced this issue Jan 31, 2017

@jimhester jimhester added this to DONE in jimhester Feb 2, 2017

jimhester added a commit to jimhester/readr that referenced this issue Feb 8, 2017

jimhester added a commit to jimhester/readr that referenced this issue Feb 9, 2017

jimhester added a commit that referenced this issue Feb 9, 2017

@kendonB

This comment has been minimized.

kendonB commented Feb 24, 2017

Thanks for the fix!

I found another case which fails, even after the fix:

problems(read_tsv("(-)\n1\n(-)", na = "", col_types = "n"))
@jimhester

This comment has been minimized.

Member

jimhester commented Feb 24, 2017

Looks correct to me, what do you expect the output to be?

library(readr)
problems(read_tsv("(-)\n1\n(-)", na = "", col_types = "n"))
#> # A tibble: 1 × 4
#>     row   col expected actual
#>   <int> <chr>    <chr>  <chr>
#> 1     2   (-) a number      -
@kendonB

This comment has been minimized.

kendonB commented Feb 25, 2017

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

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