File not read to end
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Thu Apr 26 08:53:10 EDT 2007
In <1177589949.885985.164380 at c18g2000prb.googlegroups.com>,
andrew.jefferies wrote:
> On Apr 25, 2:51 pm, Larry Bates <larry.ba... at websafe.com> wrote:
>> andrew.jeffer... at gmail.com wrote:
>> > Hi,
>>
>> > I'm trying to write a simple log parsing program. I noticed that it
>> > isn't reading my log file to the end.
>>
>> > My log is around 200,000 lines but it is stopping at line 26,428. I
>> > checked that line and there aren't any special characters.
>>
>> > This is the file reading code segment that I'm using:
>> > sysFile=open(sysFilename,'r')
>> > lineCount = 0
>> > for line in sysFile:
>> > lineCount +=1
>> > print str(lineCount) + " -- " + line
>>
>> > I also stuck this same code bit into a test script and it was able to
>> > parse the entire log without problem. Very quirky.
>
> […]
>
> I've attached the whole script. Thanks again for your help.
There are ``break`` statements in the loop body!? Do you really want to
leave the loop at those places?
And I've seen at least two times ``somefile.close`` which does just
reference the `close()` method but does not *call* it. Parenthesis are
the "call operator" in Python and they are not optional!
Ciao,
Marc 'BlackJack' Rintsch
More information about the Python-list
mailing list