Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

193
Views
analizar datos en un archivo externo

Tengo una matriz de muestra de estructuras como esta

 var array = [ {item1: 'john', item2: 'micheal'}, {item1: 'joe', item2: 'mich'}, {item1: 'jo', item2: 'mi'}, ]

Trato de analizar todos estos objetos (900 objetos en esta matriz) en otro archivo usando este código

 const fs = require('fs'); const writeStream = fs.createWriteStream('file.txt'); const pathName = writeStream.path; // write each value of the array on the file breaking line array.forEach(value => writeStream.write(`${value}\n`)); // the finish event is emitted when all data has been flushed from the stream writeStream.on('finish', () => { console.log(`wrote all the array data to file ${pathName}`); }); // handle the errors on the write process writeStream.on('error', (err) => { console.error(`There is an error writing the file ${pathName} => ${err}`) }); // close the stream writeStream.end();

Sin embargo, cuando abro el archivo obtengo

 [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object] [object Object]

que no es lo que quiero. quiero ver

 {item1: 'john', item2: 'micheal'}, {item1: 'joe', item2: 'mich'}, {item1: 'jo', item2: 'mi'},

que no es lo que veo. ¿Cómo puedo corregir esto?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!