如何使用SHINY将上传的csv文件复制到新的csv文件中? [关闭]

问题描述 投票:0回答:1

我想将UI上用户上传的CSV文件中的数据复制到我系统上的另一个CSV文件中。应以完全相同的方式复制数据。应该做什么?

r csv shiny
1个回答
1
投票

server.R:

library(shiny)
library(DT)

# Define server logic required to draw a histogram
shinyServer(function(input, output) {

  df_products_upload <- observeEvent(input$target_upload,{
    inFile <- input$target_upload
    if (is.null(inFile))
      return(NULL)
    file.copy(inFile$datapath, paste0(getwd(),"/data.csv"), overwrite = TRUE, recursive = FALSE,
              copy.mode = TRUE, copy.date = FALSE)
  })

}
)

长子。 [R

ui <- shinyUI(fluidPage(

  fileInput('target_upload', 'Choose file to upload',
            accept = c(
              'text/csv',
              'text/comma-separated-values',
              '.csv'
            ))

)
)

这会将文件复制到工作目录中的data.csv。希望这可以帮助!

© www.soinside.com 2019 - 2024. All rights reserved.