How to process the data between the lines starting with File Id
one by one. My below code gives output for 1st section , what if there are 100 + sections separated by File Id:
.
Its like I want to take the 1st section arrange the data then take up the 2nd section (File ID
) and so on. if there is a better way I would surely listen to it. Thanks.
Input file (input.txt
)
File Id: C:/my_files/00_Roll_Tom-values.txt
#RakeBoss-Random as on 12/19/2016
[groups]
met = chk\rel_io_chk, chk\dev_op_io,
div = chk\kzhr2x, chk\zz52t0, chk\czzjrt
rakeonly = chk\rzgnsd, chk\cztw5h
[/]
@met = rw
@div = rw
@rakeonly = r
File Id: C:/my_files/Rander-values.txt
#RakeBoss-Jan 21st QA
[groups]
met = chk\rel_io_chk, chk\dev_op_io
div = chk\541kmj, chk\zz52t0
app_only = chk\zz9ycd
check_io = chk\wder4, chk\zz9ycd
div_write = chk\lo98j3
year_on = chk\3w345f
[/]
@met = rw
@div = rw
@app_only= r
@check_io = r
@div_write = rw
@year_on = r
[/wedmin]
@check_io = rw
div_write= rw
[/doc/prod]
@div = rw
@app_only = r
year_on = rw
File Id: C:/my_files/456_Milo_123-values.txt
#RakeBoss-Jan 21st Prod
[groups]
met = chk\rel_io_chk, chk\dev_op_io
div = chk\kzhr2x, chk\zz52t0, chk\czzjrt, chk\pzjwr3
jee_only = chk\zz9ycd, chk\hz659l, chk\zzktgj,
check_io = chk\8u7y01, chk\zz9ycd
unique_key = chk\zz9ycd
year_on = chk\dytg6
[/]
@met = rw
@div = rw
@rakeonly = r
[/Release]
@check_io = rw
@unique_key = rw
[/Redmine/Treehub]
@div = r
@jee_only = rw
.............
...................
............. so on separated by File Id:
Code
File.open("input.txt", "r") do |f|
fight_info = f.read
m = fight_info.match(/File\sId(.+?)File\sId/m)
puts m
end