Re: Bests way to handle lines in files with only a return character?
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: 29 Dec 2005 15:44:32 -0800
Keith wrote:
> I am running into a problem with lines in a file
> I am retrieving that only have a return character in them.
> What is the best way to detect lines with only that character
> in them?
> Example
> 123.456780
> 123.567890
>
> 123.999999
> 123.888888
>
> 123.777777
>
> TIA,
>
I usualy do something like:
set line [string trim $line]
if {$line != ""} {
# Process line here ...
This way you also handle lines containing spacebars and tabs. It's also
easy to handle coments in the file in a similar fashion:
set commentChar "//"
set n [string first $commentChar $line]
if {$n != -1} {
set line [string range $line $n end]
}
set line [string trim $line]
if {$line != ""} {
# Notice that a line with only a comment
# is automatically ignored.
# Process line here ...
.
- Follow-Ups:
- Re: Bests way to handle lines in files with only a return character?
- From: Donal K. Fellows
- Re: Bests way to handle lines in files with only a return character?
- References:
- Prev by Date: Re: elapsed time
- Next by Date: Re: Getting GMT time
- Previous by thread: Re: Bests way to handle lines in files with only a return character?
- Next by thread: Re: Bests way to handle lines in files with only a return character?
- Index(es):
Relevant Pages
|