4

my folder structure is :

datasets/file.csv
source/code.ipynb

from within i want to access the file named file.csv.

import pandas as pd
data = pd.read_csv("../datasets/file.csv")

This is giving me the error : ParserError: Error tokenizing data. C error: Expected 1 fields in line 68, saw 2

How to access file using relative path in pandas python? I am using Python3.6 with Anaconda in Windows 8.1 with Jupyter notebook.

1
  • Whats the delimiter (separator) used in csv ? Commented Nov 20, 2017 at 15:54

1 Answer 1

3

The ParseError indicates that your error is in parsing the file, not locating and opening it. To verify this, try:

test_file = open('../datasets/file.csv')
for line in test_file:
    print(line.strip())

This should print out the lines in file.csv.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.