简体   繁体   中英

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 . Under Select the Timeframe, I want 6 months. The actual CSV file is at the bottom of the page where it says "Download this file in Excel format."

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.

This function wil directly import that table without having to download it:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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