Turning it into a Mesh with Weaverbird and extracting WarpWeft is one way
You might need to do a little bit manually at the corners where your input has protruding lines which aren’t part of closed quads
This grid looks like it comes from a surface or mesh though - if you have the original geometry it is coming from, it would probably be easier to sort the directions there instead of trying to extract them from just the lines.