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

Add option to specify file format to support Shiny fileInput() #85

Closed
ghost opened this issue Apr 20, 2015 · 5 comments
Closed

Add option to specify file format to support Shiny fileInput() #85

ghost opened this issue Apr 20, 2015 · 5 comments

Comments

@ghost
Copy link

ghost commented Apr 20, 2015

When a file is loaded through a fileInput() widget in a Shiny app, it appears that read_excel scans the file name to determine the file type (at least when input$file[,4] - the file path) is used. Shiny uploads an extension-less temporary file so read_excel can't open the file.

@bwbioinfo
Copy link

Hi, I ran into this problem as well and my current workaround is as follows:

           file.copy(inFile$datapath,
                      paste(inFile$datapath, ".xlsx", sep=""))
            read_excel(
                    paste(inFile$datapath, ".xlsx", sep=""), 1)

it's not the cleanest but it works.

@andrewcstewart
Copy link

thanks for the workaround @Nihasa

@faidherbard
Copy link

Hello,
This is not specific to readxl, I ran into the same issue with readr when I wanted to read_csv a zipped CSV file. readr does it right in my R scripts when it has the extension, but it fails with the extension-less temporary file uploaded by Shiny.

jirkalewandowski added a commit to jirkalewandowski/readxl that referenced this issue Jun 28, 2015
@0tertra
Copy link

0tertra commented Jul 13, 2015

to ensure that the user does upload an .xlsx file, or you need to check the extension you're self to switch between read functions. You can extract the extension as following:

update: instead of file.copy() file.rename() can be used.

ext <- tools::file_ext(inFile$name)
 file.rename(inFile$datapath,
                   paste(inFile$datapath, ext, sep="."))
 read_excel(paste(inFile$datapath, ext, sep="."), 1)

@zross
Copy link

zross commented Aug 20, 2015

I agree that adding the ability to feed read_excel() the extension would be useful, particularly in Shiny where the filename from fileInput drops the extension.

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

5 participants