Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Last active January 16, 2021 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save markmarkoh/7ff3ca8c0a92cc6f8822a6db36f29b68 to your computer and use it in GitHub Desktop.
Save markmarkoh/7ff3ca8c0a92cc6f8822a6db36f29b68 to your computer and use it in GitHub Desktop.
The many ways to fetch data from data.world

Every file and query on data.world is an API endpoint to be consumed via any language or application. Here are a few common examples:

Using a query URL

Python

import pandas as pd
df = pd.read_csv('https://query.data.world/s/zgl3zbtcq5rutbq63ttfo3lhoq4saj')

R

df <- read.csv("https://query.data.world/s/zgl3zbtcq5rutbq63ttfo3lhoq4saj", header=TRUE, stringsAsFactors=FALSE);

Javascript (d3.js)

const d3 = require('d3-dsv');
csvText = await fetch('https://query.data.world/s/mtr2limtfbsgpzemzhtc3qmanvbj2e').then(r => r.text())
parsedCsv = d3.csvParse(csvText);

Live example on Observable

CLI

curl -Ls https://query.data.world/s/mtr2limtfbsgpzemzhtc3qmanvbj2e | head -n 10

Getting a query URL

From a file:

ex

From a query:

ex

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment