I'm trying to remove empty rows from a csv document:
Document:
sentence, lingua
., pt
., in
., in
., it
., en
., pt
., pt
., en
., pt
., pt
"it's not expensive", in
"almost 50 euros the carpet is expensive", is
"price should download !!", pt
"new prices please! ??", pt
My script:
import csv
import string
with open ("test.csv", "r") as f:
csvfile = csv.reader(f, delimiter = ',')
for line in csvfile:
if line[1] == 'pt':
frases = " ".join(line[0].lower().split())
removePunct = "".join(word for word in mails if word not in string.punctuation)
noEmptyLines = " ".join(lines for lines in removePunct if len(lines) != 0)
print (noEmptyLines)
The expected result:
Price should download
new prices please
My result:
n o v o s p r o c e s p o r f e r o v e r