-1

i'm doing my first experiments with pandas and I can't succeed in opening a locally stored file.

the path of the file is the following:

:\Users\MATTEO\Desktop

and the name of the file is yelp.csv

I'm trying the following code (Python 3)

import pandas as pd


yelp_raw_data = pd.read_csv(":\Users\MATTEO\Desktop\yelp.csv")
the302storm
  • 49
  • 1
  • 6
  • What is the error you receive? Are you using Windows? Also are you sure the path isn't `'C:\...'`. – ALollz Oct 30 '18 at 20:23

2 Answers2

0

if yelp.csv is in the same directory as your .py file,

yelp_raw_data = pd.read_csv("yelp.csv")

should work fine.

0

If you're ever having trouble with the file path, you can use the absolute path:

import pandas as pd
import os

yelp_raw_data = pd.read_csv(os.path.abspath("MATTEO\Desktop\yelp.csv"))

How to get the absolute file path in python

user1394
  • 538
  • 1
  • 6
  • 17