Trying to get data from CSV file for widget

Hey everyone,

I`m pretty new to Scriptable as well as JS.
Does anyone know if there is a way to import data from a CSV in Scriptable?
I saw a lot of examples using JSON, so not sure if other formats work too.

Also, is it correct that the fetch function is not recognized?


I don’t believe there is a built in way to serialize/deserialize csvs.

fetch is not available in Scriptable since it’s a browser API. You’re looking for the Request api.

Is it feasible to invoke Pythonista or Pyto? Python has built in CSV support.

Thanks for your replies. I’ve done the deserialisation manually by splitting rows etc, so that’s fine. Just don’t have experience with the request API.
This is what I do with fetch

async function getHosp() {
  const response = await fetch('COVID19BE.csv');
  const data = await response.text();

I tried something similar with Request but that didn’t work.
Also the CSV is about 3000 lines long so that might be a bit much for a widget? :sweat_smile:


It might help if you’d post what you did “similar”. Where’s the file stored on your device, how does your URL look etc.
Also: Why don’t you try to use Filemanager to load your file? If it’s just a static file, why the need to use fetch or request?

Hi, sorry that wasn’t clear.
The CSV is in fact updated daily and is in the form of an URL , like so:

If anyone could point me in the right direction as in how to get the text data for this CSV with Request, instead of what I do with Fetch, that would be great.


Unfortunately, you didn’t post you script. It would be a lot easier to understand what you’re doing if you had.
De toute façon, cela fonctionne içi:

async function getCSV() {
  let rawFeed = await loadText("");
  return rawFeed.split('\n');

async function loadText(url) {
  let req = new Request(url)
  let txt = await req.loadString()
  return txt;

If you call getCSV, it will return the an array consisting of the CSV lines. You should be able to work from there.

1 Like

Merci chrillek.
That worked fine. It now manages to get all the data into the app. :slight_smile: