Last active
January 5, 2023 16:05
-
-
Save aagarw30/2e1bf51a163f06c0b9106c7f53710b4e to your computer and use it in GitHub Desktop.
Upload zip folder and unzip it using R and Shiny
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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