diff --git a/py/webnotes/model/import_docs.py b/py/webnotes/model/import_docs.py
index 8e1465ac86..0100eab676 100644
--- a/py/webnotes/model/import_docs.py
+++ b/py/webnotes/model/import_docs.py
@@ -343,7 +343,6 @@ class CSVImport:
self.csv_data = self.convert_csv_data_into_list(csv.reader(csv_data.splitlines()))
self.import_date_format, self.overwrite = import_date_format, overwrite
if len(self.csv_data) > 4:
-
self.doctype_data, self.labels, self.data = self.csv_data[0][:4], self.csv_data[3], self.csv_data[4:]
self.fields = []
@@ -356,12 +355,20 @@ class CSVImport:
self.validate_data()
else:
self.msg.append('
No data entered in file.
')
- return '\n'.join([m.encode('utf-8') for m in self.msg])
+
+ try:
+ out_utf8 = '\n'.join([m.encode('utf-8') for m in self.msg])
+ except UnicodeEncodeError, e:
+ out_utf8 = """We are unable to detect the encoding of the
+ given .csv file. Please save the .csv file with UTF-8
+ encoding. (See Data Import Guide -- Do you have Non-English data?)
"""
+
+ return out_utf8
def convert_csv_data_into_list(self,csv_data):
st_list = []
for s in csv_data:
- st_list.append([unicode(d, 'utf-8').strip() for d in s])
+ st_list.append([d.strip() for d in s])
return st_list
# Get Template method
diff --git a/py/webnotes/model/meta.py b/py/webnotes/model/meta.py
index b52a6eb7cd..05ba620b67 100644
--- a/py/webnotes/model/meta.py
+++ b/py/webnotes/model/meta.py
@@ -45,6 +45,7 @@ def get_link_fields(doctype):
#=================================================================================
def get_table_fields(doctype):
- return webnotes.conn.sql("select options, fieldname from tabDocField where parent='%s' and fieldtype='Table'" % doctype)
+ return webnotes.conn.sql("select options, fieldname from tabDocField \
+ where parent='%s' and fieldtype='Table'" % doctype, as_list=1)
-
\ No newline at end of file
+