I have a local json file that I'd like to search for a matching unknown record
# without having to read in the entire object (the file has over 200,00 records
}, .... that's the 1st three records of 209,578 records ... gotta read all 209,578 records (1 million, 8 hundred 86 thousand, 2 hundred 13 lines) ? ...
bleh ... lol
Re: Re: read json from file
By: Mortifis to echicken on Sat Jun 20 2020 21:43:56
}, .... that's the 1st three records of 209,578 records ... gotta read all 209,578 records (1 million, 8 hundred 86 thousand, 2 hundred 13 lines) ? ...
bleh ... lol
Not necessarily, but you'll need something more than what we have on hand.
Streaming JSON parsers for handling really large files are a thing, but I don't know if there's one that can be readily ported to our environment.
JSON.parse() only wants to parse a complete JSON string. You'd need to be able to pre-process what you're reading from the file to be sure that JSON.parse() won't choke on it.
That's tricky to do in a generic way that could handle any old JSON you throw at it.
Easier if you do it as a custom job for this particular file, and if this file is just a flat array of objects, all with the same keys and types of values. It's either going to be a bit complicated but fairly solid, or simple and hacky and maybe not super reliable.
Sysop: | Coz |
---|---|
Location: | Anoka, MN |
Users: | 2 |
Nodes: | 4 (0 / 4) |
Uptime: | 140:31:19 |
Calls: | 166 |
Files: | 5,389 |
Messages: | 223,239 |