Skip to content

Instantly share code, notes, and snippets.

@aagarw30
Last active January 5, 2023 16:05
Show Gist options
  • Save aagarw30/2e1bf51a163f06c0b9106c7f53710b4e to your computer and use it in GitHub Desktop.
Save aagarw30/2e1bf51a163f06c0b9106c7f53710b4e to your computer and use it in GitHub Desktop.
Upload zip folder and unzip it using R and Shiny
library(shiny)
ui <- fluidPage(
# Upload zip files
fileInput("file", "Upload Zip file", accept = ".zip"),
# action button to unzip the file
actionButton("unzip", "Unzip Files"),
# to display the metadata of the zipped file
tableOutput("filedf"),
# to display the list of unzipped files
tableOutput("zipped")
)
server <- function(input, output, session) {
output$filedf <- renderTable({
if(is.null(input$file)){return ()}
input$file # the file input data frame object that contains the file attributes
})
# Unzipping files on click of button and then rendering the result to dataframe
observeEvent(input$unzip,
output$zipped <- renderTable({
unzip(input$file$datapath, list = TRUE, exdir = getwd())
})
)
}
shinyApp(ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment