使用read.delim在R中读取UTF-8文件时出错

时间:2019-04-11 06:13:42

标签: r utf-8 format rstudio text-files

请在以下方面提供帮助。我正在尝试在Windows中读取UTF-8格式的文件。

PackPM <- read.delim(paste0(getwd(), "/", checkID - 1, "_", checkID - 1, "/61351004C/61351004_DMPack.txt"), sep = "~", col.names = c("..."), stringsAsFactors = F, encoding = "UTF-8")

以上脚本会产生警告,但创建的数据框格式不正确。

Warning messages:
1: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 1 appears to contain embedded nulls
2: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 2 appears to contain embedded nulls
3: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 3 appears to contain embedded nulls
4: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 4 appears to contain embedded nulls
5: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  line 5 appears to contain embedded nulls
6: In read.table(file = file, header = header, sep = sep, quote = quote,  :
  header and 'col.names' are of different lengths
7: In scan(file = file, what = what, sep = sep, quote = quote, dec = dec,  :
  embedded nul(s) found in input

请帮助。让我知道您是否需要其他详细信息。

当前语言环境:

> Sys.getlocale()
[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"

文件: enter image description here

阅读情况: enter image description here

0 个答案:

没有答案