0
votes

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.

1
This won't be so simple ! the page has a script and the csv download is initiated by the script... the result you get with your code is normal, url fetch gets what a browser gets. btw, what about your previous post (array of dates) ?Serge insas
Re: my previous post - I finally figured it out! Thanks, Stackoverflow!Throwaway
Using my answer or something else?Serge insas
I used something else because I ended up with a ton of bugs and had to rewrite the entire thing, piece by piece.Throwaway
I just renamed the file to 'txt' instead of 'csv' after downloading and after opening in Notepad I saw NO html tag, just plain text. Data being komma separated.SoftwareTester

1 Answers

0
votes

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

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