-
-
Save stephlocke/c3299992ef3ac3efe1f978bd1cb0b4b2 to your computer and use it in GitHub Desktop.
library(shiny) | |
library(data.table) | |
ui <- fluidPage( | |
titlePanel("Multiple file uploads"), | |
sidebarLayout( | |
sidebarPanel( | |
fileInput("csvs", | |
label="Upload CSVs here", | |
multiple = TRUE) | |
), | |
mainPanel( | |
textOutput("count") | |
) | |
) | |
) | |
server <- function(input, output) { | |
mycsvs<-reactive({ | |
rbindlist(lapply(input$csvs$datapath, fread), | |
use.names = TRUE, fill = TRUE) | |
}) | |
output$count <- renderText(nrow(mycsvs())) | |
} | |
shinyApp(ui = ui, server = server) |
Thanks. Could you provide an example to load multiple excel files ? At the moment each excel file has only one sheet
@KrithikaB472 To load excel files you would change fread
to readxl::read_excel
@FEI-JIANG For multiple sheets in multiple excel docs you will need a two step process - one to get a list or data.frame of workbooks and the sheets (readxl::list_sheets
) and then the lapply (or a {purrr} equivalent) to do readxl::read_excel
Thanks a lot for the code example. I tried to use it for multiple .tab files and it works nice. But one question - is it possible to save the names of the original files within the dataframe as a column? I tried ti use id.col which works outside of shiny but with that code only adds numbers.
Anyway to make this work for multiple .zip files? with a few .csv inside each?
Thank you very much !!!!
I added a step to view the data in a table, but it seems that the files (xlsx) are not actually combining. I am simply uploading a new file each time. Is there a step I am missing that combines each file I upload? Thank you so much for this demo!
You may need to ctrl+click the files @piercefa you want to upload when in your file explorer window that pops up
This is a very good example to load multiple csv/txt files. But is it possible to load multiple excels which have multiple sheets?