+ 1
Find empty Lines in csv?
How do i find and locate empty lines in a csv data sheet?
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)
+ 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')
+ 1
Thank you! With your answers i get a step closer to solve my problem.