fileInput Upload and update DT:datatable with reactive

After user has uploaded the TDMS file, I need to display its Signals in a Datatable, reactively...meaning when new TDMS file is being uploaded, that Signals in the Datatable is updated accordingly.

df_TDMS_upload <- reactive({
  inFile <- input$upload
  if (is.null(input$inFile))
    return(NULL)
  f <- file(paste0('/srv/shiny-server/data/',input$upload[1]), 'rb')
  main <- TdmsFile$new(f)
  main$read_data(f, 0, 4000, sample_rate = 1)
  mainObjectList <- as.list(main$objects)
  close(f)
  Signals <- as.data.frame(names(mainObjectList))
  return(Signals)
})
output$Signal_table <- DT::renderDataTable({
                                           Signals <- df_TDMS_upload()
                                           DT::datatable(Signals)
})

I am surprised why this does not work, it seems simple, and where is exactly the issue that it does not work?
I have debugged line by line, and when put in that filename for the tdms file, that Signals dataframe is available.

I am just puzzled why it does not work also when I try with CSV file, which is more straightforward:

df_CSV_upload <- reactive({
  inFile <- input$upload
  if (is.null(input$inFile))
    return(NULL)
  df <- read.csv('/srv/shiny-server/data/test.csv',header=TRUE, sep=',')
  return(df)
})

output$Signal_table <- DT::renderDataTable({
                                           df <- df_CSV_upload()
                                           #df <- read.csv('/srv/shiny-server/data/test.csv',header=TRUE, sep=',')
                                           DT::datatable(df)
})

And when I read directly from CSV file, then it is able to show the table contents. So where is the mistake for the reactive?

You throw away all information and keep only the names ?

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.