Public
Edited
Oct 23, 2023
Importers
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
hfParseZip = async(zipUrl, typed = false) => {
const fileName = zipUrl.split('/').pop().replace('.zip', '');
const response = await fetchp(zipUrl);
const blob = await response.blob();
const zip = await JSZip.loadAsync(blob);
const file = await zip.file(fileName);
const csvString = await file.async('string');
return d3.csvParse(csvString);
}
Insert cell
hfParseCSV = async(url, typed = false) => {
const fileName = url.split('/').pop();
const response = await fetchp(url);
const csvString = await response.text();
return d3.csvParse(csvString);
}
Insert cell
hfParseProcessingFile = async(fn, typed = false) => {
const url = `${baseUrl}${fn}`;
if (fn.endsWith('.zip')) {
return await hfParseZip(url, typed)
} else if (fn.endsWith('.csv')) {
return await hfParseCSV(url, typed)
} else {
throw new Error("Unsupported file extension.")
}
}
Insert cell
Insert cell
import {fetchp} from "@tomlarkworthy/fetchp"
Insert cell
JSZip = require('jszip@3.5.0/dist/jszip.js')
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more