uwdata / arquero

Query processing and transformation of array-backed data tables.
https://idl.uw.edu/arquero/
BSD 3-Clause "New" or "Revised" License
1.28k stars 63 forks source link

Support file loading from URL directly? #91

Closed ericemc3 closed 3 years ago

ericemc3 commented 3 years ago

The API doc exposes as an example:

// create table from an input CSV loaded from 'url'
aq.fromCSV(await fetch(url).text())

But it does not seem to work. Here are few variants:

  let url ='https://raw.githubusercontent.com/open-numbers/ddf--gapminder--systema_globalis/master/countries-etc-datapoints/ddf--datapoints--children_per_woman_total_fertility--by--geo--time.csv' ;

  return aq.fromCSV( await fetch(url).text() )  // KO
  return (await fetch(url)).text() // OK
  return aq.fromCSV( (await fetch(url)).text() )  // KO
  return aq.fromCSV( await ( (await fetch(url)).text() ) ) // OK
  return fetch(url).then(d => d.text()).then(d => aq.fromCSV(d)) // OK

Actually i wish i could use simply: aq.fromCSV(url)

like d3.csv(url)

jcmkk3 commented 3 years ago

I’ve ran into this same problem and wished for the same thing. When I’m trying to experiment with an idea, I will often use a dataset from the Tidy Tuesday Project. With Arquero, I’ve just downloaded the file because I’ve not figured out a good way to load it in by URL.

jheer commented 3 years ago

First, it looks like there is a documentation error. This should be better:

aq.fromCSV(await fetch(url).then(r => r.text()))

Second, yes, I understand the desire to load from a URL without additional fuss. However, since (loaded) CSV input and a URL are both strings, I'll need to think about potential patterns for recognizing URLs instead of actual CSV input... or consider alternative options or methods.

RandomFractals commented 3 years ago

what if you add aq.fromUrl(url) and process other data files that way, not just csv. That way you can load *.json and other data formats you might support eventually from public data sources and urls.

ericemc3 commented 3 years ago

Thank you very much for your hard work, v3.0.0 is a great new release!