csv-loader
Advanced tools
+1
-1
| { | ||
| "name": "csv-loader", | ||
| "version": "2.0.3", | ||
| "version": "2.0.4", | ||
| "description": "A webpack module to intelligently load csv files.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+28
-25
@@ -12,5 +12,11 @@ # Webpack csv loader | ||
| Install via npm: | ||
| Install with yarn: | ||
| ``` | ||
| yarn add csv-loader | ||
| ``` | ||
| Install with npm: | ||
| ``` | ||
| npm install -S csv-loader | ||
@@ -21,39 +27,36 @@ ``` | ||
| Add csv-loader to your webpack config: | ||
| Add the csv-loader to your webpack 2 configuration: | ||
| ``` javascript | ||
| const config = { | ||
| loaders : [ | ||
| { test: /\.csv$/, loader: 'csv-loader' } | ||
| ] | ||
| } | ||
| module: { | ||
| rules: [ | ||
| { | ||
| test: /\.csv$/, | ||
| loader: 'csv-loader', | ||
| options: { | ||
| dynamicTyping: true, | ||
| header: true, | ||
| skipEmptyLines: true | ||
| } | ||
| } | ||
| ] | ||
| } | ||
| ``` | ||
| This loads all .csv files with csv-loader by default. The loader will translate csv files into JSON. | ||
| The loader will translate csv files into JSON, with the following settings: | ||
| * automatically convert columns to the proper data type, | ||
| * parse the CSV header | ||
| * skip any blank lines in the file | ||
| ## Configuration | ||
| Any options supported by Papa Parse can be passed to this loader. The current API is available | ||
| Any options supported by Papa Parse can be passed to this loader with the options object. The current Papa Parse API is available | ||
| [here](http://papaparse.com/docs#config). | ||
| Add csv key to your webpack.config.js. Below is the recommended configuration, which changes Papa Parse defaults: | ||
| ``` javascript | ||
| 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. | ||
| loader will automatically figure out which deliminator to use by default. The deliminator can also be manually set. | ||
@@ -67,2 +70,2 @@ ## Credits | ||
| [npm-d]: https://img.shields.io/npm/dt/csv-loader.svg | ||
| [npm-url]: https://npmjs.com/package/csv-loader | ||
| [npm-url]: https://npmjs.com/package/csv-loader |
68
3.03%3825
-0.75%