read-excel-file
read-excel-file copied to clipboard
(Large files) 73500+ rows: RangeError: Maximum call stack size exceeded
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.
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.
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.
@kivancguckiran Did you manage to read the large xlsx file? I would like to know how you did that. Other library maybe?
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.
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
Latest changes: I've removed xpath
in [email protected]
, so the error shouldn't reappear.