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!

Help with reading a text file

Status
Not open for further replies.

sh00der

Technical User
Jul 15, 2003
58
CA
Hi, I need to extract data from a text file but the lines wrap at the end which is giving me trouble. Here's an example of the text file;

P1, Q = 0, M = 0, MT = 0, RT_FLAG = 0, RPM = 0, RAD = 0,
ANGLE_TZ = 0, ANGLE_RZ = 0;
E4, LABEL = 'E4', Q = 0, M = 0, MT = 0, RT_FLAG = 0, RPM = 0,
RAD = 0, ANGLE_TZ = 0, ANGLE_RZ = 0;

The order is inconsistent but I think that a semi-colon always indicates the end of a line. Is there a way I can read the line in up to the semi-colon rather than using

foreach line [split [read $input] \n] {blah blah blah}

Thanks
 
Did you tried:
Code:
  foreach line [split [read $input] \;] {blah blah blah}
and what happened?

Maybe you need:
Code:
  set text [string map {\n " "} $text]
HTH

ulis
 
That's got it! Had a bit of trouble with multiple splits but sorted it in the end, thanks!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top