npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vizabi/reader-ddfcsv

v4.5.3

Published

Vizabi DDFcsv reader

Readme

Vizabi DDFcsv reader

This package implements DDF model for datasets made of csv files and a datapackage.json. Once initialised, this reader can receive DDFQL queries, perform data searching, filtering, joinery etc and output an tidy data array for data visualisation.

See live example here https://observablehq.com/@vizabi/ddfcsv-reader

Install

npm i @vizabi/reader-ddfcsv

Usage

There are two implementations: for frontend and backend. Additionally, you can customise file reading plugin, so that for example backend implementation would fetch files online instead of reading locally.

  • Backend implementation is at lib/src/index.js, also usable via es6 import import DDFCsvReader from "@vizabi/reader-ddfcsv", as aliased by "main" field in package.json

  • Frontend implementation is at lib-web/src/index-web.js, also bundled and minified to dist/reader-ddfcsv.js

On Backend

//this will import "lib/src/index.js", aliased by "main" in package.json
import DDFCsvReader from "@vizabi/reader-ddfcsv"; 

//init
const readerInstance = new DDFCsvReader.getDDFCsvReaderObject();
readerInstance.init({path: "path/to/local/dataset/root"});

//test reading some concepts
const concepts = await readerInstance.read({
	from: "concepts",
	language: "en",
	select: {key: ["concept"], value: ["concept_type", "name"]},
	where: {}
})

On Frontend

On a plain webpage use

import "@vizabi/reader-ddfcsv/dist/reader-ddfcsv.js";

//init
const ddfReader = new DDFCsvReader.getDDFCsvReaderObject();
reader.init({
	path: "https://github.com/open-numbers/ddf--gapminder--fasttrack.git"
})

const data = await readerInstance.read({
	from: "datapoints",
	language: "en",
	select: {key: ["country", "time"], value: ["gdp_pcap", "lex", "pop"]},
	where: {}
})

In Observable notebooks use

DDFCsvReader = require('https://unpkg.com/@vizabi/[email protected]')

which will redirect to https://unpkg.com/@vizabi/[email protected]/dist/reader-ddfcsv.js

See the Live demo

Custom file readers

Each implementation has its own default file readers built-in:

  • FrontendFileReader is a part of lib-web/src/index-web.js version, also usable from dist/reader-ddfcsv.js
  • BackendFileReader is a part of lib/src/index.js version.

You can find in the source code and import them readers separately

import { FrontendFileReader } from "@vizabi/reader-ddfcsv/lib-web/src/index-web.js";

FrontendFileReader

This reader is designed for file reading via HTTP protocol. It uses fetch, which since v4.5.2 is no longer polyfilled

BackendFileReader

This reader is designed for file reading via OS file system. It uses fs and path

Frankensteining: Using FrontendFileReader in a Backend instance

The backend version of DDFCsvReader defaults to fs for local files. To fetch data from GitHub (or any remote source), inject the FrontendFileReader:


import DDFCsvReader from "@vizabi/reader-ddfcsv";
import { FrontendFileReader } from "@vizabi/reader-ddfcsv/lib-web/src/index-web.js";

//init
const readerInstance = new DDFCsvReader.prepareDDFCsvReaderObject(new FrontendFileReader)();
readerInstance.init({ path: "https://github.com/open-numbers/ddf--gapminder--ai_worldview_benchmark.git" });

//usage example
const concepts = await readerInstance.read({
	from: "concepts",
	language: "en",
	select: {key: ["concept"], value: ["concept_type", "name"]},
	where: {}
})

Data reading examples:

Once you can access concepts of a dataset you can run any other DDFQL query, see DDFQL specs

//typical datapoint query
data = readerInstance.read({
	from: "datapoints",
	language: "en",
	select: {key: ["country", "time"], value: ["gdp_pcap", "lex", "pop"]},
	where: {}
})

interactive example: https://observablehq.com/@vizabi/ddfcsv-reader

Build

git clone https://github.com/vizabi/reader-ddfcsv.git
cd reader-ddfcsv
npm i
npm run build

Run tests

npm test