P
P
paroletatel2020-05-26 16:54:20
Google Apps Script
paroletatel, 2020-05-26 16:54:20

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

1 answer(s)
A
Alexander Ivanov, 2020-05-26
@paroletatel

/**
 * 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);
  */
}

https://github.com/contributorpw/google-apps-script...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question