I am trying to read a CSV file using Python but I am running into errors.
import pandas as pd
import numpy as np
df = pd.read_csv('DataBase.csv')
This is my code. When I execute it, I get errors such as:
DesktopPythonDataFilesDataReader.py", line 4, in <module> df = pd.read_csv('DataBase.csv')
AppDataLocalProgramsPythonPython311Libsite-packagespandasioparsersreaders.py", line 948, in read_csv
return _read(filepath_or_buffer, kwds)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "parsers.pyx", line 579, in pandas._libs.parsers.TextReader.__cinit__
File "parsers.pyx", line 668, in pandas._libs.parsers.TextReader._get_header
File "parsers.pyx", line 879, in pandas._libs.parsers.TextReader._tokenize_rows
File "parsers.pyx", line 890, in pandas._libs.parsers.TextReader._check_tokenize_status
File "parsers.pyx", line 2050, in pandas._libs.parsers.raise_parser_error
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
I tried using
df = pd.read_csv('data.csv', encoding='latin1', quoting=csv.QUOTE_ALL)
But had the same erros. I tried it because some fields have commas in them. Still, no good. I am still new to python, so I would appreciate any help.