File processing

Chris McMillan christopherjmcmillan at eaton.com
Tue Jul 10 14:53:57 EDT 2001


When I run my script, below, it complains after the line f = open(fname,
'r') saying that it expected string, list found.  I believe this happens
because of what the glob command returns, but I'm not sure how to fix it.
FYI - I'm running Python 2.0 on Windows NT.  Thanks in advance for your
help!
Chris


import os
import glob

for fname in glob.glob('M:\\python\\*.dat'):
   fname = glob.glob('M:\\python\\*.dat')
   f = open(fname, 'r')
   lines = f.readlines()
   f.close()
   f = open(fname, 'w')
   f.writelines(lines[1:])
   f.close()






More information about the Python-list mailing list