+ 1

Find empty Lines in csv?

How do i find and locate empty lines in a csv data sheet?

23rd Dec 2018, 3:40 PM
mma
3 Respostas
+ 6
You can just skip them when reading the csv file: from csv import reader with open('data/data.csv', 'rt', encoding='utf-8') as f: csv_reader = reader(f) for line in csv_reader: if not line: continue # skip empty lines print(line)
23rd Dec 2018, 4:03 PM
Anna
Anna - avatar
+ 3
Try this code. import csv def find(): with open('example.csv','r') as f: x=csv.reader(f) new=list(x) for i in new: if(len(i)==0): print('empty line')
23rd Dec 2018, 4:07 PM
Maninder $ingh
Maninder $ingh - avatar
+ 1
Thank you! With your answers i get a step closer to solve my problem.
23rd Dec 2018, 6:22 PM
mma