r read.csv()混合编码

时间:2019-10-29 16:42:26

标签: r csv read.csv

我有一个.csv文件,我将其导入到data.frame对象中; data.frame对象然后包含一个字符列,我无法使编码正常工作。

导入的data.frame如下所示:

df <- data.frame(a = c(1, 2, 3),
                 b = c("b'Text enth\\xc3\\xa4lt Umlaute \\xe2\\x80\\x93 viele Umlaute.",
                       "b\"This text doesn't contain any unusual characters.",
                       "b'another text: http://www.google.com'"))

我尝试失败:

  • df <- read.csv(filename, fileEncoding = "UTF-8")(也是= "UTF-8-BOM"
  • df <- read.csv(filename, encoding = "UTF-8")(也是= "UTF-8-BOM")和
  • 不同的解决方案建议使用herehere来检测编码

我期望这样的结果:

  a b
1 1 "Dieser Text enthält Umlaute – viele Umlaute."
2 2 "This text doesn't contain any unusual characters."
3 3 "another text: http://www.google.com"

(请注意,已转换的\\...代码段和已删除的b' / b\"

0 个答案:

没有答案