Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

parse multiple lines text file to print in single line

Status
Not open for further replies.

Juden

Technical User
Apr 9, 2013
1
0
0
IE
I am doing some tcl scripting to parse the report with format as below and to print the output without the header and with just single line like -

Connections for net 'pmg_ccu_ot2_tam_50mhz_sel_xainfwh' :: Driver a_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh Output Pin (a_par) :: Load b_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh Input Pin (b_par)
Connections for net 'pmg_ccu_ot2_tam_50mhz_sel_xainfwh_2' :: Driver d_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh_2 Output Pin (d_par) :: Load e_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh_2 Input Pin (e_par), f_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh_3 Input Pin (f_par)
<more . . .>

I tried a few times but just could not get what I want. Really appreciate if anyone can give some light and idea to me. Thanks much!


****************************************
Report : net
-connections
Design : soc
Version: G-2012.06-SP2
Date : Sun Apr 7 22:56:33 2013
****************************************


Connections for net `pmg_ccu_ot2_tam_50mhz_sel_xainfwh`:

Driver Pins Type
------------ ----------------
a_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh Output Pin (a_par)

Load Pins Type
------------ ----------------
b_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh Input Pin (b_par)

1


Connections for net `pmg_ccu_ot2_tam_50mhz_sel_xainfwh_2`:

Driver Pins Type
------------ ----------------
d_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh_2 Output Pin (d_par)

Load Pins Type
------------ ----------------
e_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh_3 Input Pin (e_par)
f_par/pmg_ccu_ot2_tam_50mhz_sel_xainfwh_3 Input Pin (f_par)

1

<more . . .>
 
What do you know about the header: number of bytes? number of lines? If number of bytes you can read past the header:

set fid [open <filename> r]
set hdr [read $fid numbytesinheader]

Now you can read the rest into a list of lines:

set lines [split [read $fid] \n]

Now you can make that into a single line:

set strData [join $lines " "]

Now if you really wanted multiple lines (you weren't really clear):

set strData [string map {Connection \nConnection} $strData]

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top