电脑win7 64位+R version 3.2.4
要读取的csv文件是从一个xlsx文件另存为的。
但是读入的报错
> data<-read.csv("yonghu.csv",sep=" ",stringsAsFactors = F,fileEncoding = "utf-8",header=T)
Error in read.table(file = file, header = header, sep = sep, quote = quote, :
空白的文件开头
In addition: Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
invalid input found on input connection 'yonghu.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
line 1 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'yonghu.csv'
改换了编码,还是有问题
> data<-read.csv("yonghu.csv",sep=" ",stringsAsFactors = F,fileEncoding = "UCS-2LE",header=T)
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
invalid input found on input connection 'yonghu.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'yonghu.csv'
请问这是什么原因呢,如何能够正确读入数据
P.S.后来我把原xlsx文件转成txt,使用fileEncoding = "UCS-2LE是可以正确读取的,但是使用fileEncoding = "utf-8"还是会报错
所以之前用csv格式读取报错也是字符编码的问题?求各位大神指点


雷达卡




京公网安备 11010802022788号







