everybody.
I can't find a pythonic way to ignore "blank" lines in a CSV. I use quotes because I'm talking about lines that look like '','','','','' Here is a CSV (blank lines could be random):
id,name,age
1,alex,22
3,tiff,42
,,
,,
4,john,24
Here is the code:
def getDataFromCsv(path):
dataSet = []
with open(unicode(path), 'r') as stream:
reader = csv.reader(stream, delimiter=',')
reader.next() # ignoring header
for rowdata in reader:
# how to check here?
dataSet.append(rowdata)
return dataSet
Here is similar questions that I've been reading, but different to this in particular: python csv reader ignore blank row