Community
    • Login

    Regex - Extract range of XYZ coordinates

    Scheduled Pinned Locked Moved Help wanted · · · – – – · · ·
    3 Posts 2 Posters 327 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DrBubblesD
      DrBubbles
      last edited by DrBubbles

      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

      1 Reply Last reply Reply Quote 0
      • Mark OlsonM
        Mark Olson
        last edited by Mark Olson

        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.

        DrBubblesD 1 Reply Last reply Reply Quote 4
        • DrBubblesD
          DrBubbles @Mark Olson
          last edited by

          @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!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          The Community of users of the Notepad++ text editor.
          Powered by NodeBB | Contributors