How to load a csv file in Jupyter Notebook?

Hi all,

I would like to run an analysis on a csv file using Jupyter Notebooks and python.
I created a Notebook and saved the csv file in the same directory on my computer. However, I’m not able to read the csv file in the notebook. I have no clue what I’m doing wrong. Can anyone help out?

What I did so far:

import pandas as pd
df = pd.read_csv(‘COVID-19_aantallen_gemeente_per_dag.csv’)

I get this error:
ParserError Traceback (most recent call last)
in
----> 1 df = pd.read_csv(‘COVID-19_aantallen_gemeente_per_dag.csv’)

/opt/anaconda3/lib/python3.8/site-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision)
674 )
675
–> 676 return _read(filepath_or_buffer, kwds)
677
678 parser_f.name = name

/opt/anaconda3/lib/python3.8/site-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
452
453 try:
–> 454 data = parser.read(nrows)
455 finally:
456 parser.close()

/opt/anaconda3/lib/python3.8/site-packages/pandas/io/parsers.py in read(self, nrows)
1131 def read(self, nrows=None):
1132 nrows = _validate_integer(“nrows”, nrows)
-> 1133 ret = self._engine.read(nrows)
1134
1135 # May alter columns / col_dict

/opt/anaconda3/lib/python3.8/site-packages/pandas/io/parsers.py in read(self, nrows)
2035 def read(self, nrows=None):
2036 try:
-> 2037 data = self._reader.read(nrows)
2038 except StopIteration:
2039 if self._first_chunk:

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.read()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_low_memory()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._read_rows()

pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows()

pandas/_libs/parsers.pyx in pandas._libs.parsers.raise_parser_error()

ParserError: Error tokenizing data. C error: Expected 1 fields in line 228, saw 2

Ah, I already managed to fix it :partying_face:

Just realised I forgot to define the delimiter… :woman_facepalming:

2 Likes