Hi

I am looping through a directory and appending all the files in one
huge file, the codes below should give the same end results but are
not, I don't understand why the first code is not doing it.

thanks


combined = open(outputFile, 'wb')

for name in flist:
    if os.path.isdir(file): continue
    
    infile = open(os.path.join(file), 'rb')

    # CODE 1 this does not work
    tx = infile.read(1000)
    if tx == "": break
    combined.write(tx)
    infile.close()
    
    # CODE 2 but this works fine 
    for line in infile:
        combined.write(line)
    infile.close()
    
combined.close()
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to