Hi, my friends,
I have a question to ask you. I am dealing with thousands of csv files in one directory. Some of csv files are empty with file size 0. How can I skip those empty files when I open csv files otherwise it causes execution error? I have another thought that how can I check the file size for each file in that directory so that I can skip the csv files with 0 size. Is that possible? Is it possible to open a empty file in python?
Here are some codes.
listDir = os.listdir(fileDir)
for name in listDir:
dialect=csv.Sniffer().sniff(open(Name, 'r').read(1024))
fid=open(Name)
reader = csv.reader(fid, dialect)
row = 0
i = -1
for row in reader:
IBES = row[0]
thanks a lot.
John