0

Hello guys I have a assignment, which I have honestly no idea how to complete. I have a huuuge Json file which is 22 GB big, so I have to get the data from it but it's full with empty spaces and new lines and I have to trimm does before even opening the file. I tried getting the data and trim it but it says it is out of memory I even set the memory limit to -1 if anyone has any idea how is that supposed to happen please I am open to suggestions.

4
  • have you tired chunking your trimming/reading process? Commented Oct 12, 2017 at 11:35
  • Look for a JSON stream parser, allowing you to read the file bit by bit and not in one chunk. Commented Oct 12, 2017 at 11:38
  • Post your code, errors, what you have tried. We will not write the code for you. That being said, @deceze beat me to it, you have to parse the file, not try to load it and process after. Commented Oct 12, 2017 at 11:38
  • So I guess the way is to read the JSON file line by line any idea how can I get each line without reading the whole file ? Commented Oct 12, 2017 at 19:29

1 Answer 1

3

There is simple and cool parser for parsing large JSON files.

https://github.com/salsify/jsonstreamingparser

Also maybe you will find an answer on the following links
Parse large JSON file
Processing large JSON files in PHP

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.