gpt4 book ai didi

r - 从 R 中的 Excel 文件中提取超链接

转载 作者:行者123 更新时间:2023-12-04 14:27:54 26 4
gpt4 key购买 nike

关闭。这个问题不满足Stack Overflow guidelines .它目前不接受答案。












想改善这个问题吗?更新问题,使其成为 on-topic对于堆栈溢出。

7年前关闭。




Improve this question




是否可以从 R 中的 Excel 文件中提取超链接?我看了XLConnectxlsx但我唯一发现的是如何编写超链接,而不是阅读它们。

更多信息:Excel 文件在其中一列中包含超链接,这意味着您可以单击文本,将您带到文件或 URL。当我使用 XLConnect 打开文件时或 xlsx我只看到(不再可点击)文本,但我需要 URL。

最佳答案

我找到了一种 super 复杂的方法来提取超链接:

library(XML)

# rename file to .zip
my.zip.file <- sub("xlsx", "zip", my.excel.file)
file.copy(from = my.excel.file, to = my.zip.file)

# unzip the file
unzip(my.zip.file)

# unzipping produces a bunch of files which we can read using the XML package
# assume sheet1 has our data
xml <- xmlParse("xl/worksheets/sheet1.xml")

# finally grab the hyperlinks
hyperlinks <- xpathApply(xml, "//x:hyperlink/@display", namespaces="x")

源自 this blogpost .

关于r - 从 R 中的 Excel 文件中提取超链接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24149821/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com