2
I have a virtual machine with many TXT files. I usually use an ssh and pipe connection to read the files. When I use the read.csv function there is no problem at the time of reading the files. Already when I use the fread function, the business does not work. I show you the case that works first!
# my directory with the plink intallation (plink.exe)
dir<- "C/Tools/Terminal/"
setwd(dir)
user <- 'XXXXXX'
password <- 'XXXX'
dir_file_machine <- '/media/projects/'
name_file <- 'XXXXXX.TXT'
capture_file <- pipe(paste0('plink -ssh ',
user,
'@123.45.678.901 -P 12 -pw ', #fictice
password,
' "cat ',
dir_file_machine,
name_file))
a <- read.csv(capture_file, sep = ";")
Now when I use the fread function the following error happens...
capture_file <- pipe(paste0('plink -ssh ',
user,
'@123.45.678.901 -P 12 -pw ', #fictional
password,
' "cat ',
dir_file_machine,
name_file))
a <- fread(capture_file, sep = ";")
Error in fread(capture_file) :
'input' must be a single character string containing a file name, a command, full path to a file, a URL starting 'http[s]://', 'ftp[s]://' or 'file://', or the input data itself
Any idea?
The function
read.csv
accepts connections as one of the inputs. Already thefread
, no... I don’t think there’s an easy way to fix this.– Daniel Falbel
According to the comment here and the documentation, you can pass the direct command to the
fread
, without thepipe
. I have no way to test here, but in principle it should work by removing thepipe
only.– Molx
@Interesting Molx!! I withdraw my comment :P
– Daniel Falbel
Yes, it works. Thank you
– orrillo
@Molx would be nice if you put your comment as an answer, don’t you think?
– Daniel Falbel
@Danielfalbel In fact, I did not notice that it confirmed the functioning. Thank you.
– Molx