Guest_imported
New member
- Jan 1, 1970
- 0
Hi, I’m an intermittent user of awk, and need some help with a program.
I need to pull node numbers and spatial coordinates out of a data file that is not formatted in a way to make it at all convenient. (sample data inserted below, with the data I need annotated – those comments don’t appear in the real data file. The data is organized into blocks – there are various types of blocks with their own formats, but the one I’m interested in is shown.) That leaves me with the problem of matching a pattern on one line and reading data that appears on a different line in the file. [ I’ve seen several other questions like this in the archives of this forum, but I couldn’t make any of their solutions work in my case.]
16
71
4
72
4
0
VERTEX
5
57 < node numbers (in hexadecimal)
100
AcDbEntity
8
flange mesh
100
AcDbVertex
100
AcDbPolygonMeshVertex
10
8.768275930423 < x coordinate
20
0.978177227092 < y coordinate
30
0.0 <z coordinate
70
64
0
VERTEX
5
58
100
AcDbEntity
8
flange mesh
100
I’m uncertain how to attack this. I could create a set of conditions to match, but would I use the next command with it?:
/VERTEX/ {next / 5/ {node = $1} , etc.
or could I redefine the Record Separator and proceed as if each data block were one long line.
ADDED LEVEL OF DIFFICULTY: I’m working with GAWK 3.1 in an MSDOS window under Windows 98. There seem to be undocumented syntax changes compared to the manual and my experience on Unix platforms. I’m having trouble seeing if my programs fail because of hidden problems like that or my lousy programming. Any hints on living with Windows would be welcome, too.
Thanks in advance. I'll be reading "Effective AWK Programming" until I get a reply here.
Keith
I need to pull node numbers and spatial coordinates out of a data file that is not formatted in a way to make it at all convenient. (sample data inserted below, with the data I need annotated – those comments don’t appear in the real data file. The data is organized into blocks – there are various types of blocks with their own formats, but the one I’m interested in is shown.) That leaves me with the problem of matching a pattern on one line and reading data that appears on a different line in the file. [ I’ve seen several other questions like this in the archives of this forum, but I couldn’t make any of their solutions work in my case.]
16
71
4
72
4
0
VERTEX
5
57 < node numbers (in hexadecimal)
100
AcDbEntity
8
flange mesh
100
AcDbVertex
100
AcDbPolygonMeshVertex
10
8.768275930423 < x coordinate
20
0.978177227092 < y coordinate
30
0.0 <z coordinate
70
64
0
VERTEX
5
58
100
AcDbEntity
8
flange mesh
100
I’m uncertain how to attack this. I could create a set of conditions to match, but would I use the next command with it?:
/VERTEX/ {next / 5/ {node = $1} , etc.
or could I redefine the Record Separator and proceed as if each data block were one long line.
ADDED LEVEL OF DIFFICULTY: I’m working with GAWK 3.1 in an MSDOS window under Windows 98. There seem to be undocumented syntax changes compared to the manual and my experience on Unix platforms. I’m having trouble seeing if my programs fail because of hidden problems like that or my lousy programming. Any hints on living with Windows would be welcome, too.
Thanks in advance. I'll be reading "Effective AWK Programming" until I get a reply here.
Keith