全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 R语言论坛
16626 2
2016-06-10
电脑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格式读取报错也是字符编码的问题?求各位大神指点
附件列表

yonghu.zip

大小:239.99 KB

 马上下载

本附件包括:

  • yonghu.csv

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2016-6-10 16:42:18
不需要设置sep=" ",去掉fileEncoding = "utf-8"
复制代码
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2016-6-14 09:24:53
hou0922 发表于 2016-6-10 16:42
不需要设置sep=" ",去掉fileEncoding = "utf-8"
thankyou,问题已解决
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群