获取“在输入中找到的嵌入空值";使用 read.csv() 读取 csv 时 [英] Get "embedded nul(s) found in input" when reading a csv using read.csv()
本文介绍了获取“在输入中找到的嵌入空值";使用 read.csv() 读取 csv 时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在阅读一个 csv 文件.
I was reading in a csv file.
代码是:
mydata = read.csv("mycsv.csv", header=True, sep=",", quote="\"")
收到以下警告:
警告信息:在 scan(file = file, what = what, sep = sep, quote = quote, dec = dec
, :在输入中找到嵌入的空值
Warning message: In
scan(file = file, what = what, sep = sep, quote = quote, dec = dec
, : embedded nul(s) found in input
现在我的 CSV 中的某些单元格缺少用"表示的值.
Now some cells in my CSV have missing values that are represented by "".
如何编写此代码,以免收到上述警告?
How do I write this code so that I do not get the above warning?
推荐答案
您的 CSV 可能以 UTF-16 编码.在使用某些基于 Windows 的工具时,这种情况并不少见.
Your CSV might be encoded in UTF-16. This isn't uncommon when working with some Windows-based tools.
您可以尝试像这样加载 UTF-16 CSV:
You can try loading a UTF-16 CSV like this:
read.csv("mycsv.csv", ..., fileEncoding="UTF-16LE")
这篇关于获取“在输入中找到的嵌入空值";使用 read.csv() 读取 csv 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文