Probles parsing a text file

greg zorlord at zorlord.karoo.co.uk
Mon Jan 5 20:53:12 EST 2004


heres my text file(well the first two lines of it)

#########################################
#            Default BMUS server CFG file                   #

this file is written with the following code

    fi = open('bmus.cfg', 'w')
    print 'file opened'
    cfg = []
    cfg.append('#########################################\n')
    cfg.append('#            Default BMUS server CFG file
#\n')
    fi.writelines(cfg)


i heres the script that im using to parse the file

fi = open('bmus.cfg', 'r')

if fi:
    print('Reading Server CFG file')
    ll = fi.readlines()
    for line in ll:
        print(str(line))
        if line[:2] == '#' or len(line) == 0:
            pass
        else:
            eval(line)
            print("line executed")
else:
    print('Could not read Server CFG')

heres the error im getting

D:\DEMOFI~1\blender\pong1>bmus-001-thread-server.py
Reading Server CFG file
#########################################

Traceback (most recent call last):
  File "D:\DEMOFI~1\blender\pong1\bmus-001-thread-server.py", line 73, in ?
    eval(line)
  File "<string>", line 1
    #########################################

^
SyntaxError: unexpected EOF while parsing

im using one py script to ouput the txt file using \n as the end of line to
avvoide
any possible windows problems (with it using \r\n).

and then the fiel is erroring here when im reading it back into my program..

many thnas for your help

Greg Brant





More information about the Python-list mailing list