Thursday, 19 September 2013

how to skip blank line while reading CSV file using python

how to skip blank line while reading CSV file using python

This is my code i am able to print each line but when blank line appears
it prints ; because of CSV file format, so i want to skip when blank line
appears
import csv
import time
ifile = open ("C:\Users\BKA4ABT\Desktop\Test_Specification\RDBI.csv", "rb")
data = list(csv.reader(ifile, delimiter = ';'))
for line in csv.reader(ifile)):
if not line:
empty_lines += 1
continue
print line

No comments:

Post a Comment