read-excel-file icon indicating copy to clipboard operation
read-excel-file copied to clipboard

(Large files) 73500+ rows: RangeError: Maximum call stack size exceeded

Open kivancguckiran opened this issue 5 years ago • 7 comments

Hello,

I'm using the node version with below code:

const readXlsxFile = require('read-excel-file/node');

(async () => {
  const rows = await readXlsxFile('2019_07_24.xlsx');

  console.log(rows);
})();

Parsing a ~73500 rowed file, attaching. But XPATH module throws the exception: Maximum call stack size exceeded. File uploaded below.

2019_07_24.xlsx

kivancguckiran avatar Sep 05 '19 09:09 kivancguckiran

I see. Indeed, it throws that error. I won't be fixing it though: perhaps this library is not well-suited for some large Excel files. This issue will remain open for others to see.

catamphetamine avatar Sep 05 '19 09:09 catamphetamine

Unfortunately for me it's also causing RangeError: Maximum call stack size exceeded .

I came from https://github.com/daspawn/xlsx-stream-reader that also couldn't handle my 122k rows xlsx file before trying this solution. I will probably try https://github.com/SheetJS/js-xlsx next.

christiaanwesterbeek avatar Oct 19 '19 08:10 christiaanwesterbeek

@kivancguckiran Did you manage to read the large xlsx file? I would like to know how you did that. Other library maybe?

christiaanwesterbeek avatar Oct 19 '19 08:10 christiaanwesterbeek

This post is for anyone trying to read a larger excel sheet. I finally got a solution that was able to read my 122k rows excel sheet using https://github.com/SheetJS/js-xlsx :

const workbook = XLSX.read(microstrategyFile. tempFilePath, { type: 'file' });
const [firstSheetName] = workbook.SheetNames;
const worksheet = workbook.Sheets[firstSheetName];

const rows = XLSX.utils.sheet_to_json(worksheet, {
    raw: true, // Use raw values (true) or formatted strings (false)
    header: 1, // Generate an array of arrays ("2D Array")
});

I must say that the above solution is pretty memory intensive. It drove a hobby dyno on Heroku well beyond the 512mb memory limit just by running the above lines.

christiaanwesterbeek avatar Oct 20 '19 19:10 christiaanwesterbeek

Hello sorry for the late reply. I've used xlsx library. Where I have used is here.

kivancguckiran avatar Oct 20 '19 20:10 kivancguckiran

This post is for anyone trying to read a larger excel sheet. I finally got a solution that was able to read my 122k rows excel sheet using https://github.com/SheetJS/js-xlsx :

const workbook = XLSX.read(microstrategyFile. tempFilePath, { type: 'file' });
const [firstSheetName] = workbook.SheetNames;
const worksheet = workbook.Sheets[firstSheetName];

const rows = XLSX.utils.sheet_to_json(worksheet, {
    raw: true, // Use raw values (true) or formatted strings (false)
    header: 1, // Generate an array of arrays ("2D Array")
});

I must say that the above solution is pretty memory intensive. It drove a hobby dyno on Heroku well beyond the 512mb memory limit just by running the above lines.

Try this: https://www.npmjs.com/package/fast-xlsx-reader

bigabdoul avatar Jan 31 '20 19:01 bigabdoul

Latest changes: I've removed xpath in [email protected], so the error shouldn't reappear.

catamphetamine avatar Jun 17 '21 02:06 catamphetamine