将gzip数据导入Google电子表格 [英] Import gzipped data into google spreadsheet

查看:107
本文介绍了将gzip数据导入Google电子表格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图从URL中获取gzip并将其自动导入到Google Spreadsheet中。



gzip包含一个CSV数据文件。



我知道我可以将CSV数据导入到Google Spreadsheet中,但我希望能够切断我下载gzip并在上传之前首先解压文件的步骤到Google电子表格中。



因此,我的查询是否可以直接从URL中将gzipped CSV文件导入到Google Spreadsheet中?如果没有,Google Apps脚本将如何完成这项工作?

解决方案

在GAS中有一个未公开的实用程序,名为unzip,I知道它可以解压缩普通的.zip文件,但不知道是否支持GNU zip ...也许值得一试?
这里是一个快速测试,我为我的谷歌文档/驱动器编写了一个zip文件

  function testzip() {
var files = DocsList.getRootFolder()。find('Sans titre.txt.zip');
var zipblob = files [0] .getBlob();
var unzipblob = Utilities.unzip(zipblob);
var unzipstr = unzipblob [0] .getDataAsString(); //它是一个文本文件
DocsList.createFile('Sans titre.txt',unzipstr); //我保留原始名称它简单
}

不要怪我,如果它不适合你。 ..这只是一个建议; - )


I am trying to fetch a gzip from a URL and import it automatically into a Google Spreadsheet.

The gzip contains one file of CSV data.

I know I can import the CSV data into a Google Spreadsheet but I would like to be able to cut out the step of me having to download the gzip and extract the file first before uploading it into a Google Spreadsheet.

So my queries, is it possible to import a gzipped CSV file from a URL directly into a Google Spreadsheet? If not, how would this be done with a Google Apps Script?

解决方案

There is an undocumented utility in GAS called unzip, I know it can unzip ordinary .zip files but have no idea if GNU zip are supported... maybe it's worth give it a try ? here is a quick test I wrote for a zip that was in my google documents/drive

function testzip(){
var files=DocsList.getRootFolder().find('Sans titre.txt.zip');
var zipblob=files[0].getBlob();
var unzipblob = Utilities.unzip(zipblob);
var unzipstr=unzipblob[0].getDataAsString();// it is a text file
DocsList.createFile('Sans titre.txt',unzipstr);// I kept the original name to make it simple
}

Don't blame me if it doesn't work for you... it's just a proposal ;-)

这篇关于将gzip数据导入Google电子表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆