Split text and number - but keep spaces and full stops

Good day

Many of our surveyors uses a program Modelmaker to post-process their survey info. The processed info is then written out in a .tot file format. I want to write a script allowing us to easily import this information into Civil 3D as a surface. I am still stuck in trying to get the points out.

This system uses a fixed column layout for the point data, which is followed by a list of the triangles joining the points. The format of the file is as follows.

2024-02-22 19_39_10-Import ModelMaker TOT and 13 more pages - Work - Microsoft​ Edge

I was able to split the input between points and triangle data, but now I want to split the point description from the point XYZ.

The problem is - not all surveyors are equally disciplined in entering a description and sometimes some lines will have a description and other won’t, so I thought it would be best to split it by the first occurrence of a number - this led me to the following post: how-to-split-a-string-containing-letters-and-numbers implementing the script gives this:

I am not very experienced in python - is there a way - to adjust the script to keep the full stops and the spaces after it found the first occurrence of a number?
Modelmaker.dyn (29.4 KB)
Modelmaker test.txt (287 Bytes)

Why not split each line by spaces first, and then index from the end? Something like this:

lineData = line.Split(“ “)
z = float(lineData[-1])
y = float(lineData[-2])
x = float(lineData[-3])
point = Point.ByCoordinates(x,y,z)

why, yes - what a simple solution - thanks @jacob.small
with my lacking python skills, I used nodes to replicate.

1 Like