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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

TCL command

Status
Not open for further replies.

bebig

Technical User
Oct 21, 2004
111
US
hi..I have a question.

if I have this data.

1
2
3
4
5
6


then..if I want to delete or start with 3
how can I do this?

the result will be
3
4
5
6

Thank you
 
That depends on what form the data takes. If it's in a list then you can truncate the list with:
set <listname> [lrange $<listname> 2 end]

If it's in a file, you read in 2 lines before you begin processing.

Tell us more.

Bob Rashkin
rrashkin@csc.com
 
Hi,
Thank you for your comments
this is my code.
===============================
set writeAreaFile [open "area.txt" "r+"]
# read the first line
gets $readFile line
# loop for each line in the file

while {![eof $readFile]} {
set lineList [split $line ,]
set indexList0 [lindex $lineList 0]
set indexListLL [list $indexList0]
set indexListL [llength $indexListLL]
#puts $indexListL
set indexList1 [lindex $lineList 1]
set indexList2 ""
set indexList3 ""

set needs "$indexList0 $indexList1 $indexList2 $indexList3"
#puts $needs
lappend needsList $needs
#puts $needs

gets $readFile line
} ;#end of while

=================================
The result is
=================================
IM
AreaID AreaName
307 Offices/Computer Room
308 A 01
309 A 02
310 A 03
311 A 04
312 A 05
==========================

but I just need
==========================
307 Offices/Computer Room
308 A 01
309 A 02
310 A 03
311 A 04
312 A 05
===========================
Question is..
if I want to get rid of these two rows, how can I do??
IM
AreaID AreaName

thank you in advance
 
Example:
Code:
set f [open [file join [pwd] scrap.txt] r]
file4
(m) 14 % proc patternRead {fd pattern} {
set lst {}      
            while {[gets $fd line] > -1} {
                  if {[regexp $pattern $line]} {
                     lappend lst $line
                  }
             }
return $lst
}
(m) 15 % set opat "^\[0-9\]+"
^[0-9]+
(m) 16 % patternRead $f $opat
{307 Offices/Computer Room  } {308 A 01  } {309 A 02  } {310 A 03  } {311 A 04  } {312 A 05  }
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top