简体   繁体   English

从网站将CSV导入Google表格

[英]Import CSV from website to Google Sheets

The file I want to import into the Google Sheets is from the website http://www.nasdaq.com/symbol/newl/historical . 我要导入到Google表格中的文件来自网站http://www.nasdaq.com/symbol/newl/historical Under Select the Timeframe, I want 6 months. 在“选择时间范围”下,我要6个月。 The actual CSV file is at the bottom of the page where it says "Download this file in Excel format." 实际的CSV文件位于页面底部,显示为“以Excel格式下载此文件”。

I have tried: 我努力了:

var data = Utilities.parseCsv(unescape(encodeURIComponent(UrlFetchApp.fetch(url).getContentText().toString())));
var lastRow = sheet.getLastRow();
for (var i = 1; i < data.length; i++) {
sheet.getRange(i + lastRow, 1, 1, data[i].length).setValues(new Array(data[i]));

Apparently the url fetches an HTML file, not the CSV I want. 显然,该网址获取的是HTML文件,而不是我想要的CSV文件。

This function wil directly import that table without having to download it: 此函数将直接导入该表,而无需下载它:

=IMPORTHTML(" http://www.nasdaq.com/symbol/newl/historical ","table",6) = IMPORTHTML(“ http://www.nasdaq.com/symbol/newl/historical ”,“表格”,6)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM