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_csv crashed R session while read.csv or fread did not #1513

Open
tungttnguyen opened this issue Aug 31, 2023 · 0 comments
Open

read_csv crashed R session while read.csv or fread did not #1513

tungttnguyen opened this issue Aug 31, 2023 · 0 comments

Comments

@tungttnguyen
Copy link

tungttnguyen commented Aug 31, 2023

I have the following csv file which has many empty rows. Reading it using readr::read_csv() [and vroom::vroom()] crashed R session whereas base R read.csv() or data.table::fread() did not. I am wondering what the problem was? Thank you!

Reproducible example below

### get sample data file
location_id <- "ADLC1"
test_url <- paste0("https://www.cnrfc.noaa.gov/graphicalRVF_csv.php?id=", location_id)
test_data_file <- file.path(tempdir(), paste0(location_id, ".csv"))
test_data_file
download.file(test_url, test_data_file)  
### crashed R
library(readr)
test_data0 <- read_csv(test_data_file) 

### same issue with vroom
library(vroom)
test_data0 <- vroom(test_data_file, delim = ",") 
### the following codes worked
test_data0 <- read.csv(test_data_file) # works
head(test_data0)
#>   Issuance.Date.Time..Pacific. Valid.Date.Time..Pacific. Stage..Feet.
#> 1          08/30/2023 08:05 AM          08/25/2023 08 AM          0.9
#> 2          08/30/2023 08:05 AM          08/25/2023 09 AM          0.9
#> 3          08/30/2023 08:05 AM          08/25/2023 10 AM          0.9
#> 4          08/30/2023 08:05 AM          08/25/2023 11 AM          0.9
#> 5          08/30/2023 08:05 AM          08/25/2023 12 PM          0.9
#> 6          08/30/2023 08:05 AM          08/25/2023 01 PM          0.9
#>   Flow..CFS. Trend Threshold.Exceedance.Status Observed.Forecast
#> 1          6                            Normal          Observed
#> 2          7     +                      Normal          Observed
#> 3          7     0                      Normal          Observed
#> 4          8     +                      Normal          Observed
#> 5          8     +                      Normal          Observed
#> 6          8     0                      Normal          Observed

library(data.table)
test_data0 <- fread(test_data_file) # works
head(test_data0)
#>    Issuance Date/Time (Pacific) Valid Date/Time (Pacific) Stage (Feet)
#> 1:          08/30/2023 08:05 AM          08/25/2023 08 AM          0.9
#> 2:          08/30/2023 08:05 AM          08/25/2023 09 AM          0.9
#> 3:          08/30/2023 08:05 AM          08/25/2023 10 AM          0.9
#> 4:          08/30/2023 08:05 AM          08/25/2023 11 AM          0.9
#> 5:          08/30/2023 08:05 AM          08/25/2023 12 PM          0.9
#> 6:          08/30/2023 08:05 AM          08/25/2023 01 PM          0.9
#>    Flow (CFS) Trend Threshold Exceedance Status Observed/Forecast
#> 1:          6                            Normal          Observed
#> 2:          7     +                      Normal          Observed
#> 3:          7     0                      Normal          Observed
#> 4:          8     +                      Normal          Observed
#> 5:          8     +                      Normal          Observed
#> 6:          8     0                      Normal          Observed

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

Session info
sessioninfo::session_info()
#> ─ Session info ───────────────────────────────────────────────────────────────
#>  setting  value
#>  version  R version 4.3.1 (2023-06-16 ucrt)
#>  os       Windows 10 x64 (build 19045)
#>  system   x86_64, mingw32
#>  ui       RTerm
#>  language (EN)
#>  collate  English_United States.utf8
#>  ctype    English_United States.utf8
#>  tz       America/Los_Angeles
#>  date     2023-08-31
#>  pandoc   3.1.1 @ C:/Program Files/RStudio/resources/app/bin/quarto/bin/tools/ (via rmarkdown)
#> 
#> ─ Packages ───────────────────────────────────────────────────────────────────
#>  package     * version date (UTC) lib source
#>  bit           4.0.5   2022-11-15 [1] CRAN (R 4.3.0)
#>  bit64         4.0.5   2020-08-30 [1] CRAN (R 4.3.0)
#>  cli           3.6.1   2023-03-23 [1] CRAN (R 4.3.0)
#>  crayon        1.5.2   2022-09-29 [1] CRAN (R 4.3.0)
#>  digest        0.6.33  2023-07-07 [1] CRAN (R 4.3.1)
#>  evaluate      0.21    2023-05-05 [1] CRAN (R 4.3.0)
#>  fansi         1.0.4   2023-01-22 [1] CRAN (R 4.3.0)
#>  fastmap       1.1.1   2023-02-24 [1] CRAN (R 4.3.0)
#>  fs            1.6.3   2023-07-20 [1] CRAN (R 4.3.1)
#>  glue          1.6.2   2022-02-24 [1] CRAN (R 4.3.0)
#>  hms           1.1.3   2023-03-21 [1] CRAN (R 4.3.0)
#>  htmltools     0.5.6   2023-08-10 [1] CRAN (R 4.3.1)
#>  knitr         1.43    2023-05-25 [1] CRAN (R 4.3.0)
#>  lifecycle     1.0.3   2022-10-07 [1] CRAN (R 4.3.0)
#>  magrittr      2.0.3   2022-03-30 [1] CRAN (R 4.3.0)
#>  pillar        1.9.0   2023-03-22 [1] CRAN (R 4.3.0)
#>  pkgconfig     2.0.3   2019-09-22 [1] CRAN (R 4.3.0)
#>  purrr         1.0.2   2023-08-10 [1] CRAN (R 4.3.1)
#>  R.cache       0.16.0  2022-07-21 [1] CRAN (R 4.3.0)
#>  R.methodsS3   1.8.2   2022-06-13 [1] CRAN (R 4.3.0)
#>  R.oo          1.25.0  2022-06-12 [1] CRAN (R 4.3.0)
#>  R.utils       2.12.2  2022-11-11 [1] CRAN (R 4.3.0)
#>  R6            2.5.1   2021-08-19 [1] CRAN (R 4.3.0)
#>  readr       * 2.1.4   2023-02-10 [1] CRAN (R 4.3.0)
#>  reprex        2.0.2   2022-08-17 [1] CRAN (R 4.3.0)
#>  rlang         1.1.1   2023-04-28 [1] CRAN (R 4.3.0)
#>  rmarkdown     2.24    2023-08-14 [1] CRAN (R 4.3.1)
#>  rstudioapi    0.15.0  2023-07-07 [1] CRAN (R 4.3.1)
#>  sessioninfo   1.2.2   2021-12-06 [1] CRAN (R 4.3.0)
#>  styler        1.10.2  2023-08-29 [1] CRAN (R 4.3.1)
#>  tibble        3.2.1   2023-03-20 [1] CRAN (R 4.3.0)
#>  tidyselect    1.2.0   2022-10-10 [1] CRAN (R 4.3.0)
#>  tzdb          0.4.0   2023-05-12 [1] CRAN (R 4.3.0)
#>  utf8          1.2.3   2023-01-31 [1] CRAN (R 4.3.0)
#>  vctrs         0.6.3   2023-06-14 [1] CRAN (R 4.3.1)
#>  vroom       * 1.6.3   2023-04-28 [1] CRAN (R 4.3.0)
#>  withr         2.5.0   2022-03-03 [1] CRAN (R 4.3.0)
#>  xfun          0.40    2023-08-09 [1] CRAN (R 4.3.1)
#>  yaml          2.3.7   2023-01-23 [1] CRAN (R 4.3.0)
#> 
#> 
#> ──────────────────────────────────────────────────────────────────────────────
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant