multiple-csv-merge-to-json
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -17,2 +17,3 @@ /// <reference types="node" /> | ||
writeToFile?: boolean; | ||
replaceValues?: boolean; | ||
}; | ||
@@ -19,0 +20,0 @@ declare function writeOutputFile(options: MultCsvMergeToJsonOptions, jsonObj: Array<Object> | Object): void; |
@@ -84,8 +84,7 @@ "use strict"; | ||
.toUpperCase() | ||
.normalize("NFD") | ||
.replace(/[\u0300-\u036f]/g, ""); | ||
.normalize("NFD"); | ||
} | ||
return updatedObject; | ||
} | ||
function updateData(objectKeys, existingData, newData) { | ||
function updateData(objectKeys, existingData, newData, replaceValues) { | ||
let updatedData = [...existingData]; | ||
@@ -96,3 +95,3 @@ for (const data of newData) { | ||
const mergedObject = mergeObjects(existingData[indexFound], data); | ||
if (existingData[indexFound].updated) { | ||
if (!replaceValues || existingData[indexFound].updated) { | ||
updatedData.push(mergedObject); | ||
@@ -167,3 +166,3 @@ } | ||
console.log("multiple-csv-merge-to-json reading file at index %s", index + 1); | ||
outputData = updateData(options.inputKeys, outputData, fileData); | ||
outputData = updateData(options.inputKeys, outputData, fileData, options.replaceValues); | ||
console.log("multiple-csv-merge-to-json lines in buffer END ", outputData.length); | ||
@@ -176,3 +175,3 @@ }); | ||
} | ||
if (options.writeToFile) { | ||
if (!options.writeToFile || options.writeToFile === true) { | ||
writeOutputFile(options, finalObject); | ||
@@ -179,0 +178,0 @@ } |
{ | ||
"name": "multiple-csv-merge-to-json", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"description": "Merge multiple CSV files and output to JSON file", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -27,4 +27,4 @@ # multiple-csv-merge-to-json | ||
|writeToFile| Write to file, default to true | no | boolean | | ||
|replaceValues| Replace values from one file to another, default to false | no | boolean | | ||
### mergeCsvFilesToJsonArray(options: MultCsvMergeToJsonOptions) | ||
@@ -31,0 +31,0 @@ |
20076