🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Sign inDemoInstall
Socket

dsv-loader

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dsv-loader

A webpack module to load dsv (e.g. .csv or .tsv) files.

2.0.0
latest
Source
npm
Version published
Maintainers
1
Created
Source

Webpack dsv loader

A Webpack plugin for loading dsv files (for example .csv).

Installation

Install via npm:

npm install --save dsv-loader

Usage

You can require dsv data like this:

var data = require('dsv!./data.csv');
// => returns data.csv content as json parsed object

The loader will translate the data.csv file into a JSON Object.

Usage with webpack.config

To require dsv files like this: require('data.csv') , you can add the dsv-loader to your webpack config:

module : {
  loaders : [
    { test: /\.csv$/, loader: 'dsv-loader' } //will load all .csv files with dsv-loader by default
  ]
}

Options

delimiter

Tells the loader which delimiter is used to seperate the data. Default: ','

Examples:

var data = require('dsv?delimiter=;!./data.csv'); //load data seperated by semicolon

var data = require('dsv?delimiter=x!./data.csv'); //load data seperated by an 'x'

Example

data.csv

HelloWorld
42"fish"
foobar
var data = require(data.csv) //[{"Hello": "42", "World": "fish"}, {"Hello": "foo", "World": "bar"}, columns: ["Hello", "World"]]

Credits

  • Inspired by webpack's json-loader
  • DSV parsing done with dsv by Mike Bostock

Keywords

webpack

FAQs

Package last updated on 21 Dec 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts