Convert format of uploaded file


#1

Hi,

I have uploaded a .tsv file and saved it to the local directory in the server. Now I want to read the file from a script and I get he message written by me in a try() statement: file does not exist or is not a tab delimited file. I think that what happens is that the file is in the server and I cannot read from the server bu from my local PC. Could you help me with this. I do not want to download the file by using the download gui, but I would like to read a standard file stored in the server so that I can compare with a file in the PC.


#2

Hi, can you take a look at this sample app and confirm that your upload file routines work properly? http://shiny.rstudio.com/gallery/file-upload.html


#3

Yes, the file is uploaded correctly, but after uploading it I used file.copy(input$file$datapath) to save it permanently in the local server. It is saved by Shiny as 0.tsv. I will get back to you. May be I am trying to upload a file that is on the server and should be read but not uploaded.


#4

So this is the problem. When I uploaded the file I saved to the RStudio server using the following:

 observe({
    if (is.null(input$file)) return()
    #use recursive = TRUE if you want to override the same file 
   
    file.copy(input$file$datapath, "/home/giuseppa")
  
  })

The file shows up in my local directory /home/user as 0.tsv.
In my sourced script, I am trying to read the file using template<- try(read.delim(parmsDefFn, as.is=T), silent=TRUE)

  if (inherits(template, "try-error")) { # if error,
   params <- stop("Defaults params file ",basename(parmsDefFn),"either doesn't exist or is not a valid tab-separated PARAMS file. \n")
 }

and the file cannot be found. I must be doing something wrong.


#5

It works now. I change the path to parmsDefFn <- file.path("~/", "0.tsv")