from nltk.corpus import stopwords
from nltk.tokenize import word_tokenize
from string import punctuation
import csv
texto = open('arquivo_sujo.csv','r').read()
with open('arquivo_limpo.csv', 'w') as csvfile:
palavras = word_tokenize(texto.lower())
stopwords = set(stopwords.words('portuguese') + list(punctuation))
palavras_sem_stopwords = [palavra for palavra in palavras if palavra not in stopwords]
escrita = csv.writer(csvfile, delimiter=' ')
escrita.writerows(palavras_sem_stopwords)
With the writerow fix for writerows solved the problem. But how do I get the new file with the same format? Each line has one word instead of the whole sentence.