0

If I do this code in the command line:

f = open(fl, 'r')
txt = ""
for line in f:
    txt+=line
f.close()
print txt

I get all the output for the file fl, but if I do:

def editfl(self, fl):
        f = open(fl, 'r')
        txt = ""
        for line in f:
            txt+=line
        f.close()
        self.notebook_1.SetSelection(2)
        self.dedfrom = "fm"
        self.dedfl = fl
        self.text_ctrl_8.SetValue(txt)

then I only get the first 8-9 lines,
Until now it only occurs with this file (a log file generated by logkeys),
other (longer) files appear right...

What is causing the problems?

P.S.:If I try it with gedit I only get a bunch of weird not ASCII signs.
in bash, `cat` does output the content of the file right :s

Edited by Kruptein: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by vegaseat
0

You should print explicitely the content of the file using repr()

content = open(fl,'r').read()
print repr(content)

You should be able to see if your file contains wild characters. You can also try the 'rb' opening mode if you are using windows, to see if it makes any difference.

Edited by Gribouillis: n/a

0

Text files use mode "r" and the contents are usually read until they reach the EOF marker (end of file). Non ASCII files can contain an EOF marker anywhere in the file.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.