My question is: Following question, I want to achieve it in python although I have done this in bash(i have added my code at the end) but I want that to happen in python
Step1:
I have a bunch of
& merge them into one file
Step2: Now, from that
Step3:
From
My bash code which to be converted to python
Step1:
Step2:
Step3:
Step1:
I have a bunch of
Quote:.logfiles in the directory
Quote:Directory : /home/vs/vs_work2/Chi_DEPB/
& merge them into one file
Quote:merged_file.txt
Quote:Now merged_file.txt looks like as follows
PerformanceINFO
UVM_INFO_PERF ****NIB-FIB Axis Interface Per-packet Performance Report****
date : NAN,
interface_description : injection,
payload_sizes (bytes) : {312, 1100, 1132, 1404, }
packet_datarate (bits/clk): {112, 114, 113, 116, 115, 114, 114, }
Something....
something.....
PerformanceINFO
UVM_INFO_PERF ****NIB-FIB Axis Interface Per-packet Performance Report****
date : NAN,
interface_description : injection,
payload_sizes (bytes) : {312, 1100, 1132, 1404, }
packet_datarate (bits/clk): {112, 114, 113, 116, 115, 114, 114, }
Something....
something.....
PerformanceINFO
UVM_INFO_PERF ****NIB-FIB Axis Interface Per-packet Performance Report****
date : NAN,
interface_description : injection,
payload_sizes (bytes) : {312, 1100, 1132, 1404, }
packet_datarate (bits/clk): {112, 114, 113, 116, 115, 114, 114, }
Step2: Now, from that
Quote:merged_file.txtlook for PerformanceINFO and extract 6 lines every time they appear and put it in
Quote:Extracted.txt
Quote:Extracted.txt file looks like
PerformanceINFO
UVM_INFO_PERF ****NIB-FIB Axis Interface Per-packet Performance Report****
date : NAN,
interface_description : injection,
payload_sizes (bytes) : {312, 1100, 1132, 1404, }
packet_datarate (bits/clk): {112, 114, 113, 116, 115, 114, 114, }
PerformanceINFO
UVM_INFO_PERF ****NIB-FIB Axis Interface Per-packet Performance Report****
date : NAN,
interface_description : injection,
payload_sizes (bytes) : {312, 1100, 1132, 1404, }
packet_datarate (bits/clk): {112, 114, 113, 116, 115, 114, 114, }
PerformanceINFO
UVM_INFO_PERF ****NIB-FIB Axis Interface Per-packet Performance Report****
date : NAN,
interface_description : injection,
payload_sizes (bytes) : {312, 1100, 1132, 1404, }
packet_datarate (bits/clk): {112, 114, 113, 116, 115, 114, 114, }
Step3:
From
Quote:Extracted.txtfile look for
Quote:payload_sizes (bytes) & packet_datarate (bits/clk)and merge them every time they appear and put them into
Quote:output_file.csv
Quote:Output_file.csv looks like
payload_sizes(bytes): 1,2,3,4,5,6....10,100,202,303,405,5,6....10,13,24,35,45,55,65....10
packet_datarate(bits/clk):11,22,33,44,55,.....20,11,22,33,44,55,.....20,11,22,33,44,55,....
My bash code which to be converted to python
Step1:
Quote:cat /home/vs/vs_work2/Chi_DEPB/*.log > merged_file.txt
Step2:
Quote:grep -A9 -P '^PerformanceINFO *$' merged_file.txt >> Extracted.txt
Step3:
Quote:awk -F: '/packet_datarate/ { packt=packt""gensub(/[ {}]/,"","g",$2) } /payload_sizes/ { payl=payl""gensub(/[ {}]/,"","g",$2) } END { print "payload_sizes(bytes):,"payl;print "packet_datarate(bits/clk):,"packt }' Extracted.txt >> Output_file.csv