'Read/write .bdf files in Python and filter rows

I want to read specific rows from a .bdf file, modify them and then write them into a new file. Those are the ones which start with GRID, GRID* and * (example given below)

GRID*    1185                           26.875          -2.6516504287719
*       -6.875
GRID*    1186                           26.25           -1.7677669525146
*       -6.25
GRID*    1187                           25.625          -.88388347625732
*       -5.625
GRID     1189           -25.     0.     -5.
GRID     1190           -23.75   0.     -5.
GRID     1191           -22.5    0.     -5.
GRID     1192           -21.25   0.     -5.

Afterwards I want to modify some data from them and put it into another file, keeping the same format and order as before (else NASTRAN won't read the file correctly, it requires 8 character sintax). Any suggestions?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source