r - 使用 read.csv() 读取 csv 时获取 "embedded nul(s) found in input"

标签 r

我正在读取 csv 文件。

代码是:

mydata = read.csv("mycsv.csv", header=True, sep=",", quote="\"")

收到以下警告:

Warning message: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec, : embedded nul(s) found in input

现在,我的 CSV 中的某些单元格缺少由“”表示的值。

如何编写此代码才能避免收到上述警告?

最佳答案

您的 CSV 可能采用 UTF-16 编码。使用某些基于 Windows 的工具时,这种情况并不罕见。

您可以尝试像这样加载 UTF-16 CSV:

read.csv("mycsv.csv", ..., fileEncoding="UTF-16LE")

关于r - 使用 read.csv() 读取 csv 时获取 "embedded nul(s) found in input",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23209464/

相关文章:

r - 如何在没有for循环的情况下连接矩阵的列重复

r - 当有 NA 值时,我可以让 geom_smooth() 允许换行吗?

r - 如何将轴添加到 3D 直方图 (rgl)

RMarkdown IO 幻灯片演示不再支持 css 文件中的背景图片

r - 解析出字符串,将其设置为 R data.table 中的因子列

r - 如何在 blogdown 中使用 bibtex 进行引用?

r - ggplot : Plotting the bins on x-axis and the average on y-axis

r - 更改默认提示和R中的输出行前缀?

r - 从 R 中的两个表中查找不重叠的值

r - gauher(k) 错误 : object 'gh' not found using difGenLord function