KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a CSV text file encoded in UTF-16 (so as to preserve Unicode characters when others use Excel) but when doing a read_csv with Pandas 0.9.0, I get this cryptic error: df = pd.read_csv('data.txt',encoding='utf-16',sep='\t',header=0) df.head() --------------------------------------------------------------------------- Exception Traceback (most recent call last) <ipython-input-18-85da1383cd9e> in <module>() ----> 1 df = pd.read_csv('candidates-spanish.txt',encoding='utf-16',sep='\t',header=0) 2 df.head() /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/parsers.pyc in read_csv(filepath_or_buffer, sep, dialect, header, index_col, names, skiprows, na_values, keep_default_na, thousands, comment, parse_dates, keep_date_col, dayfirst, date_parser, nrows, iterator, chunksize, skip_footer, converters, verbose, delimiter, encoding, squeeze, **kwds) 248 kdict['delimiter'] = sep 249 --> 250 return _read(TextParser, filepath_or_buffer, kdict) 251 252 @Appender(_read_table_doc) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/parsers.pyc in _read(cls, filepath_or_buffer, kwds) 198 return parser 199 --> 200 return parser.get_chunk() 201 202 @Appender(_read_csv_doc) /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/parsers.pyc in get_chunk(self, rows) 853 elif not self._has_complex_date_col: 854 index = self._get_simple_index(alldata, columns) --> 855 index = self._agg_index(index) 856 857 elif self._has_complex_date_col: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pandas/io/parsers.pyc in _agg_index(self, index, try_parse_dates) 980 arr, _ = _convert_types(arr, col_na_values) 981 arrays.append(arr) --> 982 index = MultiIndex.from_array
Tags (comma-separated)
Save Edits
Cancel