Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

184
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda