使用带有符号链接文件的 read.csv [英] Using read.csv with a symlinked file
问题描述
我想做什么
我的源文件非常大,我想避免将其复制到其他文件夹中.我决定创建一个指向大文件的符号链接,并希望使用 read.csv
读取文件.
My source file is very large and I want to avoid copying it into other folders. I decided to create a symlink to the large file and want to use read.csv
to read in the file.
文件夹结构
- project1/data/source-file.csv
- project2/data/alias-to-source-file.csv
出了什么问题
在源文件中读取工作正常,但是当我尝试在符号链接中读取时,出现以下错误:第 1 行似乎包含嵌入的空值
.
Reading in the source file works perfectly, but when I try to read in the symlink, I get the following error: line 1 appears to contain embedded nulls
.
我知道我可以复制文件并将其放入我的第二个项目的文件夹中,但我想知道是否有使用符号链接的方法.如果没有,我想知道一种避免跨多个项目复制数据文件的好方法.
I know that I can just duplicate the file and put it into my second project's folder, but I want to know if there is a way to use symlinks. If not, I would like to know of a good way to avoid duplicating data files across many projects.
推荐答案
符号链接在我的系统上正确制作时有效.
Symlinks work when made correctly on my system.
> read.csv("foo.csv")
X1 X2 X3
1 3 4 5
2 5 6 7
> system("ln -s foo.csv bar.csv")
> read.csv("bar.csv")
X1 X2 X3
1 3 4 5
2 5 6 7
错误的符号链接会产生错误,但我无法复制您的错误:
Bad symlinks can produce errors, but I can't replicate your error:
指向不存在文件的符号链接:
Symlink to non-existent file:
> system("ln -s nonsuch.csv baz.csv")
> read.csv("baz.csv")
Error in file(file, "rt") : cannot open the connection
In addition: Warning message:
In file(file, "rt") : cannot open file 'baz.csv': No such file or directory
链接到现有目录文件夹:
Link to existent directory folder:
> system("ln -s / qux.csv")
> read.csv("qux.csv")
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
no lines available in input
这篇关于使用带有符号链接文件的 read.csv的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!