我正在读取 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/