Filter parts array
Remove objects that have a part value which matches the rejectedParts list
This commit is contained in:
parent
8d2bb35521
commit
e40ccc2bd6
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
._*
|
._*
|
||||||
node_modules/
|
node_modules/
|
||||||
|
*.csv
|
23
index.js
23
index.js
@ -1,12 +1,31 @@
|
|||||||
const csvFilePath = './mkII.csv'
|
const csvFilePath = './tweed57_smt.csv'
|
||||||
const csv = require('csvtojson')
|
const csv = require('csvtojson')
|
||||||
|
|
||||||
|
// Which components should we remove from the BOM?
|
||||||
|
const rejectedParts = [
|
||||||
|
'TP1',
|
||||||
|
'TP2',
|
||||||
|
'TP3',
|
||||||
|
'G',
|
||||||
|
'U$1',
|
||||||
|
'J1',
|
||||||
|
'J2',
|
||||||
|
'INPUT'
|
||||||
|
]
|
||||||
|
|
||||||
|
// Return false if the Part value of the object passed in is in the list to remove
|
||||||
|
function isJunk (element) {
|
||||||
|
return !rejectedParts.includes(element.Part)
|
||||||
|
}
|
||||||
|
|
||||||
csv({
|
csv({
|
||||||
delimiter: ";",
|
delimiter: ";",
|
||||||
includeColumns: /(Part|Value)/,
|
includeColumns: /(Part|Value)/,
|
||||||
ignoreEmpty: true
|
ignoreEmpty: true
|
||||||
})
|
})
|
||||||
.fromFile(csvFilePath)
|
.fromFile(csvFilePath)
|
||||||
.then(parts => {
|
.then(jsonObj => {
|
||||||
|
// Create array containing only relevant parts
|
||||||
|
let parts = jsonObj.filter(isJunk)
|
||||||
console.log(parts)
|
console.log(parts)
|
||||||
})
|
})
|
Loading…
x
Reference in New Issue
Block a user