Package Exports
- csv-loader
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (csv-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Webpack csv loader
Purpose
This CSV loader automatically converts data types, making it easy to import and start using data.
Installation
Install via npm:
npm install -S csv-loader
Usage
Add csv-loader to your webpack config:
const config = {
loaders : [
{ test: /\.csv$/, loader: 'csv-loader' }
]
}
This loads all .csv files with csv-loader by default. The loader will translate csv files into JSON.
Configuration
Any options supported by Papa Parse can be passed to this loader. The current API is available here.
Add csv key to your webpack.config.js. Below is the recommended configuration, which changes Papa Parse defaults:
const config = {
loaders : [
{ test: /\.csv$/, loader: 'csv-loader' }
],
csv: {
dynamicTyping: true,
header: true,
skipEmptyLines: true
}
}
This will automatically convert columns to the proper data type, parse the CSV header, and skip any blank lines in the file.
Not just a CSV loader
This module works with any column based file separated by deliminators. Simply set which extension to parse and the loader will automatically figure out which deliminator to use.
Credits
- Inspired by dsv-loader
- CSV parsing done with Papa Parse