r - 从 r 中的 Azure blob 解压缩 .gz 文件
问题描述
我想从 Azure blob 容器中读取 .csv.gz,但我正在为 .gz 格式而苦苦挣扎。当我在本地下载文件然后用 R 在 R 中读取它时,它工作正常。但是当我尝试从 Azure 中读取它时,该文件没有正确读取。文件似乎没有解压缩。这是我用来读取本地文件的代码(read_csv2 也可以正常工作):
df<-read_delim("filename.csv.gz", delim=";",col_names=c('epoch','SegmentID','TT','Speed','LoS','Coverage'),
col_types=cols(epoch = col_integer(),SegmentID = col_integer(),TT = col_integer(),Speed = col_integer(),LoS = col_integer(),Coverage = col_integer()))
这就是我尝试从 Azure 获取文件的方法:
blob_urls_with_sas<-paste("https://name.blob.core.windows.net","/container/filename.csv.gz",
sas_token, sep="")
dfAzure<-read_delim(blob_urls_with_sas,delim=";",
col_names=c('epoch','SegmentID','TT','Speed','LoS','Coverage'),
col_types=cols(epoch = col_integer(),SegmentID = col_integer(),TT = col_integer(),
Speed = col_integer(),LoS = col_integer(),Coverage =col_integer()))
或来自 AzureStor 包
test <- storage_read_delim(cont, "filename.csv.gz",delim=";",
col_names=c('epoch','SegmentID','TT','Speed','LoS','Coverage'), col_types=cols(epoch = col_integer(),SegmentID = col_integer(),TT = col_integer(),
Speed = col_integer(),LoS = col_integer(),Coverage = col_integer()))
解决方案
一种选择是使用自然处理文件fread()
的 data.table 。.gz
确保您R.utils
先安装。
推荐阅读
- mysql - 如何在节点 mysql 中使用 IF EXISTS 语句?
- linux - 一个 linux 连接到另一个 ip,如何使用 docker 将它们制作成图像并部署到其他地方
- java - 如何在 Eclipse 中运行 maven 项目(打印出“Hello Word”)
- elasticsearch - 查询更新:如果一个或多个项目不匹配,带有多个语句的内联脚本 ctx 会失败?
- powershell - 根据列表中的项目检查复选框中的项目1
- go - Golang 嵌入式结构
- jhipster - 为什么在创建 JHipser 项目时添加附加组件 (primeNG) 不起作用
- facebook-graph-api - 应用程序没有能力在 GRAPH API 上进行此 API 调用
- html - 如何将一个类设置为div
- excel - 如何在 VBA excel 中使用高级过滤器增加循环