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

257
Vistas
How can I parse a large spreadsheet file using sheetJS and stream reading?

I'm currently working on writing a prebuild script for a Nextjs project that will download some data and parse it into a json file.

I found the SheetJS package which seems to do everything I need. The issue is, the ODS file I'm trying to parse is large (40k+ records) and I'm getting the following error when trying to run my script:

'Error: Cannot create a string longer than 0x1fffffe8 characters'

I've done some reading online, and the solution seems to be 'Stream reading'.

There's an example about quarter of the way down the Sheetjs readme 'Explicitly concatenating streams' which I've used as a base to create the following code.

It's running perfectly on a small file with a single line of data in the spreadsheet, but when I try and run it with the full sized spreadsheet, I'm still getting the error.

I'm guessing I might be going wrong with the stream reading part? Any advice would be much appreciated.

var XLSX = require('xlsx');
var fs = require('fs');

var parseData = async () => {
  var file = fs.createReadStream('./data/data.ods');
  function process_RS(stream, cb) {
    var buffers = [];
    stream.on('data', function (data) {
      buffers.push(data);
    });
    stream.on('end', function () {
      var buffer = Buffer.concat(buffers);
      var workbook = XLSX.read(buffer, { type: 'buffer' });

      /* DO SOMETHING WITH workbook IN THE CALLBACK */
      cb(workbook);
    });
  }

  process_RS(file, (workbook) => {
    var data = XLSX.utils.sheet_to_json(workbook['Sheets']['Cars'], {
      range: 7,
      header: ['Make', 'Model'],
    });
    console.log(data);
  });
};

parseData();

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