Python Forum
Newbie, can't load csv file. - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: Newbie, can't load csv file. (/thread-9532.html)



Newbie, can't load csv file. - david_ford - Apr-15-2018

I keep getting the same error on this. The first row of the csv is column names, but they are not in double quotes. Might that be the issue?

(
Quote:base) C:\Users\DSNoS>python
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from datascience import Table
>>> casesissuesproviders=Table.read_table('C:/users/dsnos/desktop/CaseIssuesProviders.csv')
Traceback (most recent call last):
File "pandas/_libs/parsers.pyx", line 1175, in pandas._libs.parsers.TextReader._convert_tokens
File "pandas/_libs/parsers.pyx", line 1281, in pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas/_libs/parsers.pyx", line 1297, in pandas._libs.parsers.TextReader._string_convert
File "pandas/_libs/parsers.pyx", line 1539, in pandas._libs.parsers._string_box_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 7: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\DSNoS\Anaconda3\lib\site-packages\datascience\tables.py", line 132, in read_table
df = pandas.read_table(filepath_or_buffer, *args, **vargs)
File "C:\Users\DSNoS\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 709, in parser_f
return _read(filepath_or_buffer, kwds)
File "C:\Users\DSNoS\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 455, in _read
data = parser.read(nrows)
File "C:\Users\DSNoS\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1069, in read
ret = self._engine.read(nrows)
File "C:\Users\DSNoS\Anaconda3\lib\site-packages\pandas\io\parsers.py", line 1839, in read
data = self._reader.read(nrows)
File "pandas/_libs/parsers.pyx", line 902, in pandas._libs.parsers.TextReader.read
File "pandas/_libs/parsers.pyx", line 924, in pandas._libs.parsers.TextReader._read_low_memory
File "pandas/_libs/parsers.pyx", line 1001, in pandas._libs.parsers.TextReader._read_rows
File "pandas/_libs/parsers.pyx", line 1130, in pandas._libs.parsers.TextReader._convert_column_data
File "pandas/_libs/parsers.pyx", line 1182, in pandas._libs.parsers.TextReader._convert_tokens
File "pandas/_libs/parsers.pyx", line 1281, in pandas._libs.parsers.TextReader._convert_with_dtype
File "pandas/_libs/parsers.pyx", line 1297, in pandas._libs.parsers.TextReader._string_convert
File "pandas/_libs/parsers.pyx", line 1539, in pandas._libs.parsers._string_box_utf8
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 7: invalid start byte
>>>

changed encoding and it worked. Sorry for the bother. I should google first. Newbie frantic thrashing, what can I say.


RE: Newbie, can't load csv file. - sparkz_alot - Apr-15-2018

Quote:UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 7: invalid start byte

Is telling you it has encountered a character it cannot decode. It would be helpful to see the relevant code and a few lines of the .csv file.


RE: Newbie, can't load csv file. - snippsat - Apr-15-2018

Look at this Thread,and see if you can pick up some tips.