0

I'm working on a project that involves manipulating node coordinates from an ANSYS .inp file. I'm trying to extract the node coordinates, modify them (e.g., multiply the z-coordinate by 1.5), and then write the modified data back to a file. However, I'm encountering difficulties parsing the file correctly due to its specific format. Here's an example of the node coordinate data in the .inp file:

The format is: Node ID (integer), a zero value, and X, Y, Z coordinates (scientific notation).


1 0 0-3.3131786040000E-002 4.5036802300000E-002-1.2229753440000E-001
2 0 0-2.7267243100000E-002 3.7109654860000E-002-1.2437740980000E-001
3 0 0-2.0034116490000E-002 3.0278565420000E-002-1.2621129580000E-001

The challenges I'm facing: There are no spaces between the Y and Z coordinates, I've tried using regular expressions and converting it to other file types such as csv, but I haven't been able to correctly extract the coordinates. What would be the most efficient way to extract the node coordinates correctly? I am coding in Python. Any help/advice is greatly appreciated!

I've tried using regular expressions and converting it to other file types such as csv, but I haven't been able to correctly extract the coordinates. Here's an example output from when I tried converting the inp file into a csv file.

Node_ID,X,Y,Z
1,-3.3131786040000E-0,0,2
2,-2.7267243100000E-0,0,2
3,-2.0034116490000E-0,0,2
2
  • There is nothing regular or methodological to advise, except one thing: don't put yourself in the situation when you deal with a pathological data input, the result of someone's sloppiness. There can be an ad-doc advice only. First, pay attention that the format takes the fixed string size. Therefore, you can extract the substring at the end of input the string by the size. That's it. Commented Jan 22 at 22:55
  • Do you know what the format is for values with a positive power of E? Is it E+005, E 005, E005 or perhaps something else? Commented Jan 29 at 14:18

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.