Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support file loading from URL directly? #91

Closed
ericemc3 opened this issue Feb 5, 2021 · 4 comments · Fixed by #101
Closed

Support file loading from URL directly? #91

ericemc3 opened this issue Feb 5, 2021 · 4 comments · Fixed by #101
Labels
enhancement New feature or request

Comments

@ericemc3
Copy link

ericemc3 commented Feb 5, 2021

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
Copy link

jcmkk3 commented Feb 5, 2021

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
Copy link
Member

jheer commented Feb 5, 2021

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.

@jheer jheer changed the title proper use of fromCSV() with a url Support file loading from URL directly? Feb 5, 2021
@jheer jheer added the enhancement New feature or request label Feb 5, 2021
@RandomFractals
Copy link

RandomFractals commented Feb 5, 2021

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.

This was referenced Feb 9, 2021
@ericemc3
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants