text_plain_output_1.png
import pandas as pd

import re

path = '../input/'
TRAIN_DATA_FILE = f'{path}train.csv'
TEST_DATA_FILE = f'{path}test.csv'
train = pd.read_csv(TRAIN_DATA_FILE, header=0)
test = pd.read_csv(TEST_DATA_FILE, header=0)
print('Read %d labeled train reviews and  %d unlabelled test reviews' % (len(train), len(test)))
all_comments = train['comment_text'].fillna('_na_').tolist() + test['comment_text'].fillna('_na_').tolist()
with open('all_comments.csv', 'w+') as comments_file:
    i = 0
    for comment in all_comments:
        comment = re.sub('[^a-zA-Z]', ' ', str(comment))
        comments_file.write('%s\n' % comment)