英文:
Read Excel-file from sftp server
问题
我想从一个受密码保护的ftp服务器读取一个.xlsx文件到我的R中。
使用getURL,我能够访问文件并获取它们的名称,例如"sftp://datasource.eex-group.com/market_data/power/ch/derivatives/xls/2023/PowerFutureHistory_CH_2023.xlsx",但然后我不知道如何在R中读取/导入这个xlsx文件。
如果路径名中有空格,例如"sftp://datasource.eex-group.com/market data/power/ch/derivatives/xls/2023/PowerFutureHistory_CH_2023.xlsx",这会有问题吗?
英文:
I would like to read an .xlsx-File from a password protected ftp-Server into my R.
With getURL I'm able to address the files and get their names, for example "sftp://datasource.eex-group.com/market_data/power/ch/derivatives/xls/2023/PowerFutureHistory_CH_2023.xlsx", but then I don't know how to read/import this xlsx-file into R.
Is it a problem, if the path name has a blank, e.g. "sftp://datasource.eex-group.com/market data/power/ch/derivatives/xls/2023/PowerFutureHistory_CH_2023.xlsx"
答案1
得分: 0
感谢您的评论。
关于密码保护部分,我在https://stackoverflow.com/questions/5420506/reading-information-from-a-password-protected-site 找到了答案。关于下载Excel/CSV文件,我在https://stackoverflow.com/questions/59645148/how-to-simply-download-an-excel-file-directly-from-the-internet-with-r 找到了相关信息。
结合使用时,它完美运行。
url = "sftp://user:passwd@server:port";
file.server <- paste0(url, path.server, "Excelfile_name_server.xlsx");
file.local <- paste0(path.local, "Excelfile_name_local.xlsx");
download.file(file.server, destfile = file.local, mode = "wb");
英文:
Thanks for the comments.
I found the answer on https://stackoverflow.com/questions/5420506/reading-information-from-a-password-protected-site for the password protected part and https://stackoverflow.com/questions/59645148/how-to-simply-download-an-excel-file-directly-from-the-internet-with-r
for downloading the excel/csv-file.
In combination it works perfectly.
url = "sftp://user:passwd@server:port"
file.server <- paste0(url, path.server, "Excelfile_name_server.xlsx")
file.local <- paste0(path.local, "Excelfile_name_local.xlsx")
download.file(file.server, destfile = file.local, mode = "wb")
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论