I have a txt file that I split by the tabs, then I map out each line to an array. I would like to make these arrays
[
"saddle (seat)",
"asiento"
],
[
"seat clamp",
"abrazadera de asiento"
],
Into something like this, using Eng and Spa as properties:
{ Eng: saddle (seat),
Spa: asiento,
Eng: seat clamp,
Spa: abrazadera de asiento
}
This is my current code
var fs = require('fs');
var output = fs.readFileSync('component names.txt', 'utf8')
.replace(/(\r)/gm, "")
.split('\n')
.map(line => line.split('\t'))
/* .reduce(() => {}, )
components = []
components[].push({
Eng: line[0],
Spa: line[1]
}) */
console.log('output:', JSON.stringify(output, null, 2));
arr= [{Eng: "saddle (seat)", Spa: "asiento"} ,{Eng: "someEng", Spa:"someSpa"}, ...]