Answer the question
In order to leave comments, you need to log in
How to use data from a file by reference using a script?
There is a link https://www.cnb.cz/cs/financni-trhy/devizovy-trh/k... which returns a text document with the exchange rates of the Czech Central Bank. I want to set up currency conversion using this information.
How to present the data from this link as a String?
Answer the question
In order to leave comments, you need to log in
/**
* Get currencies by a date
*/
function run() {
const httpResponse = UrlFetchApp.fetch(
'https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/denni_kurz.txt?date=20.05.2020'
);
const data = Utilities.newBlob(httpResponse.getContent(), 'plain/text')
.getDataAsString()
.split('\n')
.map((line) => line.split('|'))
.slice(1);
console.log(data);
/*
// Paste to a sheet
sheet.getRange(1, 1, data.length, data[0].length).setValues(data);
*/
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question