@wmfs/smithereens
Advanced tools
Comparing version 1.2.0 to 1.3.0
@@ -0,1 +1,18 @@ | ||
# [1.3.0](https://github.com/wmfs/smithereens/compare/v1.2.0...v1.3.0) (2018-08-09) | ||
### ✨ Features | ||
* File description extended to allow constants to be part of the output csv. ([9a475c0](https://github.com/wmfs/smithereens/commit/9a475c0)) | ||
### 🐛 Bug Fixes | ||
* **Transformer:** standard ([cb970fa](https://github.com/wmfs/smithereens/commit/cb970fa)) | ||
### 🛠 Builds | ||
* **deps-dev:** update semantic-release requirement from 15.9.5 to 15.9.6 ([e098e61](https://github.com/wmfs/smithereens/commit/e098e61)) | ||
# [1.2.0](https://github.com/wmfs/smithereens/compare/v1.1.1...v1.2.0) (2018-08-06) | ||
@@ -2,0 +19,0 @@ |
@@ -26,2 +26,5 @@ 'use strict' | ||
break | ||
case 'constant': | ||
_this.columnFunctions.push(Transformer.constantFn(outputColumnConfig.value)) | ||
break | ||
default: | ||
@@ -42,2 +45,6 @@ console.error('ERROR: Unknown outputColumnType ' + outputColumnType) | ||
static constantFn (value) { | ||
return () => value | ||
} // contstantFn | ||
transform (incomingCsvLine) { | ||
@@ -44,0 +51,0 @@ if (this.hasColumnFunctions) { |
{ | ||
"name": "@wmfs/smithereens", | ||
"version": "1.2.0", | ||
"version": "1.3.0", | ||
"description": "Smash CSV files into more manageable files based on column values", | ||
@@ -46,3 +46,3 @@ "author": "West Midlands Fire Service", | ||
"nyc": "12.0.2", | ||
"semantic-release": "15.9.5", | ||
"semantic-release": "15.9.6", | ||
"standard": "11.0.1", | ||
@@ -49,0 +49,0 @@ "@semantic-release/changelog": "3.0.0", |
@@ -11,6 +11,6 @@ # smithereens | ||
[![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/wmfs/tymly/blob/master/packages/pg-concat/LICENSE) | ||
> Smash CSV files into more manageable files based on column values | ||
@@ -45,3 +45,3 @@ | ||
{ | ||
outputDirRootPath: '/some/output/dir', | ||
@@ -56,3 +56,3 @@ | ||
}, | ||
dirSplits: [ | ||
@@ -67,3 +67,3 @@ { | ||
], | ||
fileSplits: { | ||
@@ -89,5 +89,5 @@ columnIndex: 4, | ||
}, | ||
function (err, manifest) { | ||
// File output | ||
@@ -112,3 +112,3 @@ // ----------- | ||
// unknown.csv: | ||
// 50,Maggie,Simpson,c,x | ||
// 50,Maggie,Simpson,c,x | ||
// ./unknown | ||
@@ -143,3 +143,3 @@ // changes.csv: | ||
Configures how to parse incoming CSV lines. Uses [csv-streamify](https://www.npmjs.com/package/csv-streamify) under the bonnet. | ||
Configures how to parse incoming CSV lines. Uses [csv-streamify](https://www.npmjs.com/package/csv-streamify) under the bonnet. | ||
@@ -156,3 +156,3 @@ | Property | Type | Description | | ||
Smithereens can break CSV files across a nested set of directories based on values defined in each line. | ||
Smithereens can break CSV files across a nested set of directories based on values defined in each line. | ||
@@ -166,3 +166,3 @@ | Property | Type | Description | | ||
In a similar way, Smithereens can route lines to different files, based on the contents of a parsed CSV column. | ||
In a similar way, Smithereens can route lines to different files, based on the contents of a parsed CSV column. | ||
@@ -176,3 +176,3 @@ | Property | Type | Description | | ||
Defines which filename a CSV row should be routed to, along with some output-formatting configuration. | ||
Defines which filename a CSV row should be routed to, along with some output-formatting configuration. | ||
@@ -182,5 +182,17 @@ | Property | Type | Description | | ||
| `filename` | `string` | The filename which a row should be routed to. All output files will be in CSV format. Note that the `.csv` extension is added automatically, so don't include it here. | | ||
| `outputColumns` | `[object]` | An array of objects - each defining a column that should appear in the output file. Each object in this array should contain two properties: `name` refers to the column header name (as included in the first line of each output file) and `columnIndex` identifies a value in the parsed incoming CSV array to use. | | ||
| `outputColumns` | `[object]` | An array of `outputColumn` objects - each defining a column that should appear in the output file. | | ||
### `outputColumn` object | ||
Defines the values for each column in the output. | ||
| Property | Type | Description | | ||
| --- | ---- | ----- | | ||
| `name` | string | The name of the column, used in the first line of the CSV output | | ||
| `columnIndex` | integer | Identifies the column in the corresponding row of the parsed incoming CSV array to copy to the output. If `columnIndex` is given any `type` parameter is ignored. | | ||
| `type` | string | Describes other output - `hash`, `uuid`, `constant`. `hash` generates a hash value from the contents of the corresponding input row, `uuid` outputs a unique id, `constant` output a fix value, given by the `value` property. | | ||
| `value` | number or string | A fixed value to put output when the `type` property is `constant`. | | ||
## <a name="test"></a>Testing | ||
@@ -187,0 +199,0 @@ |
{ | ||
"outputDirRootPath": "/home/travis/build/wmfs/smithereens/test/output", | ||
"started": "2018-08-06T12:08:37.660Z", | ||
"finished": "2018-08-06T12:08:37.687Z", | ||
"started": "2018-08-09T09:34:42.475Z", | ||
"finished": "2018-08-09T09:34:42.508Z", | ||
"filenamePaths": { | ||
@@ -6,0 +6,0 @@ "changes": [ |
@@ -55,3 +55,5 @@ /* eslint-env mocha */ | ||
{name: 'last_name', columnIndex: 2}, | ||
{name: 'hash_sum', type: 'hash'} | ||
{name: 'hash_sum', type: 'hash'}, | ||
{name: 'integer', type: 'constant', value: 1}, | ||
{name: 'string', type: 'constant', value: 'pig'} | ||
] | ||
@@ -58,0 +60,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
35220
567
196