Hi, Guys,
I use RG to handle some txt files in Python to rearrange format of these text files. These text files look like below
MATERIAL
NAME=STEEL IDES=S W=76819.55
T=0 E=1.99948E+11 U=.3 A=.0000117 FY=3.447379E+08
NAME=CONC2 IDES=C W=23560
T=0 E=2.48211E+10 U=.2 A=.0000099
NAME=OTHER IDES=N W=76819.55
T=0 E=1.99948E+11 U=.3 A=.0000117
NAME=CON3 IDES=C W=23560
T=0 E=2.48211E+10 U=.2 A=.0000099
FRAME SECTION
NAME=CON450X450 MAT=CONC2 SH=R T=.45,.45
NAME=FSEC1 MAT=CON3 SH=P T=.3048
NAME=B200 MAT=CONC2 SH=R T=.16,.2
NAME=B300 MAT=CONC2 SH=R T=.16,.3
NAME=B400 MAT=CONC2 SH=R T=.16,.4
NAME=B400H MAT=CONC2 SH=R T=.16,.4
SHELL SECTION
NAME=WALL1 MAT=CONC2 TYPE=Shell,Thin TH=.25
NAME=SLAB1 MAT=CON3 TYPE=Shell,Thin TH=.25
NAME=DECK1 MAT=CONC2 TYPE=Membr TH=.0889
NAME=PLANK1 MAT=CONC2 TYPE=Membr TH=.25
NAME=SLAB2 MAT=CONC2 TYPE=Shell,Thin TH=1
I am using simple RE to identify location of useful information below
for line1 in alllines:
shelltype=re.search('TYPE=Shell',line1)
if shelltype is not None:
....
However, as I am a new user, I doe not know
1) how to locate range of these useful information, for instance from which line to which line in a text file
for example: can I locate the number of the line on which only "FRAME SECTION" exists
2) how to extract values for example .45,0.45 or 1.99948e+11
3) how to assign these extracted values into some variables so that I can call these variables later on
Could you please give me some help? thank you so much.
Ning