【发布时间】:2015-03-27 23:43:04
【问题描述】:
我遇到了与here 中的解释相同的问题,唯一的区别是 CSV 文件包含 non_english 字符串,我找不到任何解决方案: 当我读取未编码的 csv 文件时,它没有给我任何错误,但数据更改为:
network=read.csv("graph1.csv",header=TRUE)
اشپیل(60*4)
如果我用fileEncoding 运行read.csv,它会给我这个错误:
network=read.csv("graph1.csv",fileEncoding="UTF-8",header=TRUE)
Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote, :
invalid input found on input connection 'graph1.csv'
2: In read.table(file = file, header = header, sep = sep, quote = quote, :
incomplete final line found by readTableHeader on 'graph1.csv'
network[1]
[1] X.
<0 rows> (or 0-length row.names)
系统信息:
windows server 2008
R:R3.1.2
示例文件:
node1,node2,weight
ورق800*750*6,ورق 1350*1230*6mm,0.600000024
ورق900*1200*6,ورق 1350*1230*6mm,0.600000024
ورق76*173,ورق 1350*1230*6mm,0.600000024
ورق76*345,ورق 1350*1230*6mm,0.600000024
ورق800*200*4,ورق 1350*1230*6mm,0.600000024
【问题讨论】:
-
它只是整个文件没有正确读取的列名。
-
第二个警告应该根据我的回答解决,因为你忘记了回车。
-
对于它的价值,示例文件在 Mac 上完美运行(假设系统区域设置为 UTF-8),并且两个代码 sn-ps 工作 - 这几乎肯定是一个特定于 Windows 的问题,因为 Windows 下 R 下的 Unicode 支持非常简陋。
-
您应该通过在末尾放置 EOD 分隔符来获得以下结果(我也称为回车)