【问题标题】:Import "dirty" .xls with read.xls使用 read.xls 导入“脏”.xls
【发布时间】:2015-12-14 17:03:06
【问题描述】:

我想使用 read.xls 从 Internet 导入一个 .xls 文件。我已经调整了要跳过的行和编码,但它仍然不起作用! 对此有什么想法吗? Excel 文件是否“脏”了?

library("gdata")
read.xls("http://www.gsi-berlin.info/redirectA.asp?filename=TS1200199029201312.xls", 
         sheet=2, skip=5, fileEncoding="utf8")

【问题讨论】:

  • 导入不起作用。

标签: r excel import


【解决方案1】:

编辑:

尝试改用readxl。这似乎效果更好。

library(readxl)

# Need to download the file first
df <- read_excel("/.../TS1200199029201312.xls", sheet=2, skip=5)

head(df)

  01011101            Stülerstr. 0.130378
1 01011102     Großer Tiergarten        x
2 01011103            Lützowstr. 0.451560
3 01011104            Körnerstr. 0.191847
4 01011105  Nördl. Landwehrkanal        x
5 01011201           Wilhelmstr.        .
6 01011202 Unter den Linden Nord        x

【讨论】:

  • .xls 的第一行数据丢失,skip=4 无法修复。此外,编码被破坏并添加 file.encoding="utf8" 使命令再次错误...mhhh...
  • @Gui_struggling_with_R 查看我的编辑。尝试改用readxls,因为它需要更少的参数来获得你想要的东西,但你必须先下载文件。希望这会有所帮助
猜你喜欢
  • 2014-03-11
  • 2014-01-14
  • 2015-11-21
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-10-21
相关资源
最近更新 更多