[Tutor] What is missing?

Ramkumar Kashyap rkashyap@sympatico.ca
Sun, 03 Feb 2002 23:15:20 -0500


import os
import time

DIR = "D:\\dp_test"
for filename in os.listdir(DIR):
    full_path = os.path.join(DIR, filename)
    myFile = open(full_path, 'r')
    inFile = open('dp_hr.txt', 'w')
    count = len(myFile.readlines())
    print filename + ",", count     
    inFile.write(filename + ', ' + string(count))

Hi!
There are 325 files in the directory. The program works up until the 
print statement which displays all the 325 files with the corresponding 
lines contained in the respective files. The write statement only writes 
the last file and line_numbers for the last file. Should I put it in 
another loop?

regards,

Kumar