dreamRs / datamods

Shiny modules to import and manipulate data into an application or addin
https://dreamrs.github.io/datamods/
GNU General Public License v3.0
138 stars 35 forks source link

Can't load *.dat files after update #79

Closed ProfessorPeregrine closed 6 months ago

ProfessorPeregrine commented 11 months ago

Previously, my app would load text files with a .dat extension (usually they would be tab-delimited). Now it says " Ooops Format not supported"

Is there a way to add this functionality back? There are many legacy files that loaded just fine that I will have to change the extension on now if not.

Thanks again for an amazing package!

pvictor commented 11 months ago

Hello, It seems that package rio no longer support .dat files, this produce an error :

readr::write_delim(mtcars, file = "mtcars.dat")
rio::import(file = "mtcars.dat")

if you want to be able to import .dat files with datamods you can still specify the function to use manually for this specific extension :

imported <- import_file_server(
  id = "myid",
  read_fns = list(
    dat = function(file) {
      readr::read_delim(file = file)
    }
  )
)

Victor

ProfessorPeregrine commented 11 months ago

Thanks Victor. How would this work with modal import? I see that import_modal() doesn’t have the read_fns parameter.

From my app:

Data Import

observeEvent(input$launch_modal, {

req(input$from)

import_modal(

  id = "modal_import",

  from = input$from,

  title = "Import data to be used in application"

)

})

imported <- import_server("modal_import", return_class = "data.frame")

Steven Ouellette, MS, CMC®

President

http://www.roi-ally.com/ The ROI Alliance, LLC

From: Victor Perrier @.> Sent: Wednesday, November 8, 2023 3:59 AM To: dreamRs/datamods @.> Cc: ProfessorPeregrine @.>; Author @.> Subject: Re: [dreamRs/datamods] Can't load *.dat files after update (Issue #79)

Hello, It seems that package rio https://github.com/gesistsa/rio no longer support .dat files, this produce an error :

readr::write_delim(mtcars, file = "mtcars.dat") rio::import(file = "mtcars.dat")

if you want to be able to import .dat files with datamods you can still specify the function to use manually for this specific extension :

imported <- import_file_server( id = "myid", read_fns = list( dat = function(file) { readr::read_delim(file = file) } ) )

Victor

— Reply to this email directly, view it on GitHub https://github.com/dreamRs/datamods/issues/79#issuecomment-1801644228 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AV6KQR4NP4YXZVWJ2NOJKNLYDNQXZAVCNFSM6AAAAAA6YM24AOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRGY2DIMRSHA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AV6KQR4IDZQY47HVDXQARDTYDNQXZA5CNFSM6AAAAAA6YM24AOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTLMLUMI.gif Message ID: @. @.> >

pvictor commented 11 months ago

Be sure to use latest version, import_server() should have a read_fns argument.

ProfessorPeregrine commented 11 months ago

Aha, got it! Thanks!

Steven Ouellette, MS, CMC®

President

http://www.roi-ally.com/ The ROI Alliance, LLC

From: Victor Perrier @.> Sent: Wednesday, November 8, 2023 10:09 AM To: dreamRs/datamods @.> Cc: ProfessorPeregrine @.>; Author @.> Subject: Re: [dreamRs/datamods] Can't load *.dat files after update (Issue #79)

Be sure to use latest version, import_server() should have a read_fns argument.

— Reply to this email directly, view it on GitHub https://github.com/dreamRs/datamods/issues/79#issuecomment-1802312307 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AV6KQR5WKMW2IGGB4FRTO6DYDO4EPAVCNFSM6AAAAAA6YM24AOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBSGMYTEMZQG4 . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AV6KQR57JJAU3HYIOODLRILYDO4EPA5CNFSM6AAAAAA6YM24AOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTLNUNHG.gif Message ID: @. @.> >

ProfessorPeregrine commented 11 months ago

Hmm, this change doesn’t seem to allow single-column text files to be loaded, even though readr has no problem with it. Files with more than one column delimted by tabs seem to work fine.

The attached file gives the “oops” message.

Steven Ouellette, MS, CMC®

President

http://www.roi-ally.com/ The ROI Alliance, LLC

From: Victor Perrier @.> Sent: Wednesday, November 8, 2023 3:59 AM To: dreamRs/datamods @.> Cc: ProfessorPeregrine @.>; Author @.> Subject: Re: [dreamRs/datamods] Can't load *.dat files after update (Issue #79)

Hello, It seems that package rio https://github.com/gesistsa/rio no longer support .dat files, this produce an error :

readr::write_delim(mtcars, file = "mtcars.dat") rio::import(file = "mtcars.dat")

if you want to be able to import .dat files with datamods you can still specify the function to use manually for this specific extension :

imported <- import_file_server( id = "myid", read_fns = list( dat = function(file) { readr::read_delim(file = file) } ) )

Victor

— Reply to this email directly, view it on GitHub https://github.com/dreamRs/datamods/issues/79#issuecomment-1801644228 , or unsubscribe https://github.com/notifications/unsubscribe-auth/AV6KQR4NP4YXZVWJ2NOJKNLYDNQXZAVCNFSM6AAAAAA6YM24AOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRGY2DIMRSHA . You are receiving this because you authored the thread. https://github.com/notifications/beacon/AV6KQR4IDZQY47HVDXQARDTYDNQXZA5CNFSM6AAAAAA6YM24AOWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTLMLUMI.gif Message ID: @. @.> >

pvictor commented 11 months ago

Seems to be a readr error, for single column file you have to explicitly set delim = " ", e.g. :

readr::write_delim(mtcars[, 1, drop = FALSE], file = "mtcars1.dat")

readr::read_delim(file = "mtcars1.dat")
# Error: Could not guess the delimiter.
# 
# Use `vroom(delim =)` to specify one explicitly.

readr::read_delim(file = "mtcars1.dat", delim = " ")
# Rows: 32 Columns: 1                                                                                                                                                                                                                                           
# ── Column specification ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
# Delimiter: " "
# dbl (1): mpg
# 
# ℹ Use `spec()` to retrieve the full column specification for this data.
# ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
# # A tibble: 32 × 1
#     mpg
#   <dbl>
# 1  21  
# 2  21  
# 3  22.8
# 4  21.4
# 5  18.7
# 6  18.1
# 7  14.3
# 8  24.4
# 9  22.8
# 10  19.2
# # ℹ 22 more rows
# # ℹ Use `print(n = ...)` to see more rows
chainsawriot commented 4 months ago

@pvictor @ProfessorPeregrine Sorry for the breaking change. Will fix this here gesistsa/rio#430 .

pvictor commented 3 months ago

Thank you @chainsawriot ! Great work 👍

ProfessorPeregrine commented 3 months ago

Thank you @chainsawriot !