Converting text to numbers

I am trying to convert these text into numbers so I can visualize the points. I have tried to trim whitespace and check if any symbols are in the way of the conversion. Any suggestions would be great!


Text to Num.gh (33.3 KB)

Post your GH file

This looks like a job for a simple regular expression \d+\.?\d* might be a good pattern. You can see how it works at

I used as test data

F=1800
G01
Z1472.000
Y1630.682

That gives as result

Addendum: of course it is then easy to add simple tests to find the X, Y and Z parts, then combine those into coordinates.

Text to Num.gh (33.3 KB)

Text to Num.gh (33.3 KB)
here is the GH file Sorry for not posting it

Not sure exactly what you’re after, but this should get you started. This python script will convert your input text to a list of x, y, z values and create points with these values. It skips lines that don’t contain “X”, “Y”, and “Z”.

These are the points created with the data in your file:

Text to Num_re.gh (37.8 KB)

-Kevin

1 Like

Thanks! I also found the solution after a bit of messing around with the script again.

You can also use components

1 Like