Regex - Extract range of XYZ coordinates
-
I have almost no regex knowledge and wouldn’t even know how to approach my problem. I’m not even sure if what I’m trying to do is possible at all… if it is, I’d really appreciate any pointers!
I have a huge json file (10 GB) containing 3D coordinates in this format:
“coords”:{“x”:-26997.03125,“y”:-48.75,“z”:53262.78125}Now, what I’d like to do is extract all entries within a range of X, Y and Z. Say, everything between -20 and +20 for each axis. As you can see in the example, the coordinates are usually different in length.
Can that be done using regex?
Cheers -
Can that be done using regex?
Not if you value your sanity. See this FAQ for some reasons why.
One additional reason that the FAQ doesn’t mention is that regular expressions don’t let you do math like selecting all numbers between -20 and 20.
I have a huge json file (10 GB)
Even if you could use regular expressions to do this, I VERY strongly urge you abandon all hope of doing these edits inside any text editor, including Notepad++. I doubt Notepad++ could even open the file without crashing due to running out of memory.
Your best bet is probably to use some tool that reads JSON in a stream rather than loading it all into memory at once, and this is a problem for a programming language, not for Notepad++.
EDIT: If your file was much smaller (like maybe 10 MB instead of 10 GB), I think JsonTools would be a reasonable solution. But I can’t recommend JsonTools for any file larger than 50 MB, even if you could technically use it for larger files than that. Also, it is literally impossible for JsonTools to parse a file larger than about 2 GB, because it uses 32-bit signed integers to index into strings.
-
@Mark-Olson Thanks for your response, appreciate it! I’ll look into other options then. I can actually open the file in Notepad++ but it sure takes a while to load.
Anyway, thanks again!