Re: Read block of file in Tcl



calvin hobbes wrote:
>
> Hi,
>
> I have an input file in the following format:
> ********************************
> Name1
> Name2
> Row1 DEF 001
> Row2 ABC DEG 003
> Row3 EW EW 002
> Row4 FF 0012
> Row1 ADEF 1001
> Row2 ARBC DEG 2003
> Row3 EWW EW 0302
> Row4 AB 0112
> Name1
> Name2
> Row1 DSDEF 001
> Row2 ABVC DEG 003
> Row3 EDW EW 002
> Row4 FVF 0012
> Row1 AF 1001
> Row2 ACRBC DEG 2003
> Row3 ESWW EW 0302
> Row4 AEB 0112
> ****************************************
> I have to read this file and
> --> if I get "Name1" in any of the line,
> then I have to read the block of file from "Name1" to the first
> occurrance
> of "Row4".
> --> If I get "Row1" after the above reading is done, then I have to
> read
> the block of file from "Row1" to the first occurrance of "Row4".
>
> Can anyone help me out in doing this through TCL.
>
> Thanks and regards,
> Calvin

You question has the characteristics of a homework assignment.
Just a few hints:
- [gets] lets you read a file line by line
- the while loop may prove useful

Regards,

Arjen
.



Relevant Pages

  • Read block of file in Tcl
    ... Row4 FF 0012 ... Row1 ADEF 1001 ... Row2 ARBC DEG 2003 ... Row3 EWW EW 0302 ...
    (comp.lang.tcl)
  • Comparing Columns and Counting
    ... Row2 - Impaired - Tested ... Row3 - Impaired - Not Tested ... Row1 - Impaired - Tested ... of the 2 drivers was impaired, ...
    (microsoft.public.excel.misc)
  • Re: Same text in column as one
    ... Row2 Aaaaaaa ... Row4 Ddddddd ... Row3 Ccccccc ... Row6 Zzzzzzz ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Same text in column as one
    ... Row2 Aaaaaaa ... Row4 Ddddddd ... Row3 Ccccccc ... Row6 Zzzzzzz ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Simple XSLT Question?
    ... <ROW1> ... <ROW2> ... <ROW3> ... <ROW31> ...
    (microsoft.public.dotnet.xml)