Search code examples
javascriptjsonreactjsjsonlines

Reading large json lines files in javascript / react


I got a large file (300MB) that is saved in jsonlines. Means the file containes thousands of javascript objects, separated by line breaks.

Unfortunatelly I have no idea how to work with a file like this. Can anyone give me some kind of short introduction on how to handle such files?


Solution

  • Don't use React/ don't handle it at the Client. In Node.JS, you can read such files directly (fs.readFileSync(...).split('\n').map((row) => JSON.parse(row))). If they are larger, use a line by line reader and JSON.parse(). Search at npm for that.