{"action":"closed","issue":{"url":"https://api.github.com/repos/hadley/readr/issues/491","repository_url":"https://api.github.com/repos/hadley/readr","labels_url":"https://api.github.com/repos/hadley/readr/issues/491/labels{/name}","comments_url":"https://api.github.com/repos/hadley/readr/issues/491/comments","events_url":"https://api.github.com/repos/hadley/readr/issues/491/events","html_url":"https://github.com/hadley/readr/issues/491","id":167221797,"number":491,"title":"unzipping read_csv in shiny app","user":{"login":"garthtarr","id":2189134,"avatar_url":"https://avatars.githubusercontent.com/u/2189134?v=3","gravatar_id":"","url":"https://api.github.com/users/garthtarr","html_url":"https://github.com/garthtarr","followers_url":"https://api.github.com/users/garthtarr/followers","following_url":"https://api.github.com/users/garthtarr/following{/other_user}","gists_url":"https://api.github.com/users/garthtarr/gists{/gist_id}","starred_url":"https://api.github.com/users/garthtarr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garthtarr/subscriptions","organizations_url":"https://api.github.com/users/garthtarr/orgs","repos_url":"https://api.github.com/users/garthtarr/repos","events_url":"https://api.github.com/users/garthtarr/events{/privacy}","received_events_url":"https://api.github.com/users/garthtarr/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-24T07:37:35Z","updated_at":"2016-07-24T12:29:32Z","closed_at":"2016-07-24T12:29:32Z","body":"The automatic file decompression feature is awesome.  I'm trying to get it working in a shiny app, but I'm running into some issues.  Here's a MWE for the app and two example files are:\r\n\r\n[mtcars.csv](https://www.dropbox.com/s/gdw6piyitsbpwbe/mtcars.csv?dl=1)\r\n[mtcars.zip](https://www.dropbox.com/s/1uu1jyg7q5kgce8/mtcars.zip?dl=1)\r\n\r\n```{r}\r\nlibrary(shiny)\r\nlibrary(readr)\r\n\r\nui <- fluidPage(\r\n   titlePanel(\"Test upload\"),\r\n   sidebarLayout(\r\n      sidebarPanel(\r\n        fileInput('file1', 'Upload csv file or zipped csv file')\r\n      ),\r\n      mainPanel(\r\n         tableOutput(\"tabOut\")\r\n      )\r\n   )\r\n)\r\n\r\nserver <- function(input, output) {\r\n   output$tabOut <- renderTable({\r\n     inFile <- input$file1\r\n     validate(\r\n       need(!is.null(input$file1), \"Please upload a data file\")\r\n     )\r\n     dat <- read_csv(inFile$datapath)\r\n     return(dat)\r\n   })\r\n}\r\n\r\n# Run the application \r\nshinyApp(ui = ui, server = server)\r\n```\r\n\r\nI would expect the app to return the same result, whether the file uploaded was a csv or a zipped version of the csv, much like\r\n\r\n```{r}\r\nread_csv(\"mtcars.zip\")\r\n```\r\n\r\nand\r\n\r\n```{r}\r\nread_csv(\"mtcars.csv\")\r\n```\r\n\r\nreturn the same object.  However, when I upload a zipped csv file, in the shiny app it returns the error: `Error: input string 2 is invalid UTF-8` and in the console it returns:\r\n\r\n```\r\n> runApp()\r\n\r\nListening on http://127.0.0.1:6254\r\nParsed with column specification:\r\ncols(\r\n  `PK\u0003\u0004\u0014` = col_character()\r\n)\r\nWarning: 4 parsing failures.\r\nrow            col expected        actual\r\n  1 PK\u0003\u0004\u0014          embedded null\r\n  5 PK\u0003\u0004\u0014          embedded null\r\n  7 PK\u0003\u0004\u0014          embedded null\r\n  8 PK\u0003\u0004\u0014          embedded null\r\n\r\nWarning: Error in gsub: input string 2 is invalid UTF-8\r\nStack trace (innermost first):\r\n    86: gsub\r\n    85: sanitize\r\n    84: print.xtable\r\n    83: <Anonymous>\r\n    82: do.call\r\n    81: eval\r\n    80: eval\r\n    79: withVisible\r\n    78: evalVis\r\n    77: utils::capture.output\r\n    76: paste\r\n    75: origRenderFunc\r\n    74: output$tabOut\r\n     1: runApp\r\n```\r\n\r\nMy session info:\r\n\r\n```\r\n> devtools::session_info()\r\nSession info -------------------------------------------------------------------------------------------\r\n setting  value                       \r\n version  R version 3.3.1 (2016-06-21)\r\n system   x86_64, darwin13.4.0        \r\n ui       RStudio (0.99.1266)         \r\n language (EN)                        \r\n collate  en_AU.UTF-8                 \r\n tz       Australia/Sydney            \r\n date     2016-07-24                  \r\n\r\nPackages -----------------------------------------------------------------------------------------------\r\n package    * version     date       source                        \r\n assertthat   0.1         2013-12-06 CRAN (R 3.3.0)                \r\n devtools     1.12.0      2016-06-24 CRAN (R 3.3.0)                \r\n digest       0.6.9       2016-01-08 CRAN (R 3.3.0)                \r\n htmltools    0.3.5       2016-03-21 CRAN (R 3.3.0)                \r\n httpuv       1.3.3       2015-08-04 CRAN (R 3.3.0)                \r\n jsonlite     1.0         2016-07-01 CRAN (R 3.3.0)                \r\n memoise      1.0.0       2016-01-29 CRAN (R 3.3.0)                \r\n mime         0.5         2016-07-07 CRAN (R 3.3.0)                \r\n R6           2.1.2       2016-01-26 CRAN (R 3.3.0)                \r\n Rcpp         0.12.6      2016-07-19 cran (@0.12.6)                \r\n readr      * 0.2.2.9000  2016-07-24 Github (hadley/readr@8b1b81b) \r\n rsconnect    0.4.3       2016-05-02 CRAN (R 3.3.0)                \r\n shiny      * 0.13.2.9004 2016-07-24 Github (rstudio/shiny@28547e9)\r\n tibble       1.1         2016-07-04 CRAN (R 3.3.0)                \r\n withr        1.0.2       2016-06-20 CRAN (R 3.3.0)                \r\n xtable       1.8-2       2016-02-05 CRAN (R 3.3.0) \r\n```"}}
{"actor":{"display_login":"hadley"}}