在 R 中读取 csv +unicode

标签 r csv encoding

我遇到了与 here 中的解释相同的问题,唯一的区别是 CSV 文件包含 non_english 字符串,我找不到任何解决方案:
当我读取没有编码的 csv 文件时,它没有给我任何错误,但数据更改为:

network=read.csv("graph1.csv",header=TRUE)

  اشپیل(60*4)

如果我运行 read.csvfileEncoding它给了我这个错误:
 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

最佳答案

我试过你的输入:

> read.csv("graph1.csv", encoding="UTF-8")
                      X.U.FEFF.node1                                  node2 weight
1  <U+0648><U+0631><U+0642>800*750*6 <U+0648><U+0631><U+0642> 1350*1230*6mm    0.6
2 <U+0648><U+0631><U+0642>900*1200*6 <U+0648><U+0631><U+0642> 1350*1230*6mm    0.6
3     <U+0648><U+0631><U+0642>76*173 <U+0648><U+0631><U+0642> 1350*1230*6mm    0.6
4     <U+0648><U+0631><U+0642>76*345 <U+0648><U+0631><U+0642> 1350*1230*6mm    0.6
5  <U+0648><U+0631><U+0642>800*200*4 <U+0648><U+0631><U+0642> 1350*1230*6mm    0.6

关于在 R 中读取 csv +unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28203015/

相关文章:

r - 使用 prcomp 和我自己在 R 中进行主成分分析 : different results

python - “外来”字符在列表的最后位置时丢失

r - 有什么方法可以强制 data.table 的 fread() 不要停在空行上?

python - Rpy2 完全支持 ggplot2.layer 吗?

python - csvkit:对于 csv 到 Table,当

java.io.FileNotFoundException,系统找不到指定的路径(cvs文件)java

使用英文和中文字符时ASP中的编码问题

PHP GD imagettftext 字符编码,符号缺失

c - C 中的 R 包依赖于另一个 R 包

linux - Unix - 对特定输出进行排序