使用R读取xlsm文件时出错

时间:2018-02-28 09:44:05

标签: r xlsm

我有一个xlsm文件(请看下面的照片),我想:

  • 跳过前4行
  • 使用第5行作为变量名称

我尝试使用read_csv("Sujet8.xlsm", skip = 4),但它返回了我的错误:

Error in read.table(file = file, header = header, sep = sep, quote = quote,  : 
no lines available in input
In addition: Warning messages:
1: In readLines(file, skip) : line 1 appears to contain an embedded nul
2: In readLines(file, skip) : line 2 appears to contain an embedded nul
3: In readLines(file, skip) : incomplete final line found on 'Sujet8.xlsm'

我还尝试了readxl包。

data_types = c("text","text")
my_data = read_excel("Sujet8.xlsm", sheet = "Sheet2", skip = 4, na = "n/a", col_types = data_types)

但是它给我发了这个错误:

Error in read_fun(path = path, sheet = sheet, limits = limits, shim = shim,  : 
Sheet 1 has 52 columns, but `col_types` has length 2.

我该如何解决这个问题?抱歉,我无法共享该文件,因为它仅供内部使用。但这是它的外观。

enter image description here

0 个答案:

没有答案