From 6aa4b52678dd39d2555f8b4f43e9ebd6cdf6fba0 Mon Sep 17 00:00:00 2001 From: Sanwal Yousaf Date: Wed, 6 Mar 2019 13:24:04 -0500 Subject: [PATCH] Updating the read privileges in the open statement In python 3+, you need to open the .csv file as a read-only privilege with the encoding of cp1252 or else the code won't work properly. --- process_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/process_data.py b/process_data.py index c5ab027..b8479e7 100644 --- a/process_data.py +++ b/process_data.py @@ -15,7 +15,7 @@ def build_data_cv(datafile, cv=10, clean_string=True): revs = [] vocab = defaultdict(float) - with open(datafile, "rb") as csvf: + with open(datafile, "r", encoding = 'cp1252') as csvf: csvreader=csv.reader(csvf,delimiter=',',quotechar='"') first_line=True for line in csvreader: