cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How to read a file in pandas in a databricks environment?

tinendra
New Contributor III

Hi,

When I was trying to read the CSV files using pandas I am getting an error which I have mentioned below.

df=pd.read_csv("/dbfs/FileStore/tables/badrecord-1.csv")

Error: FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/tables/badrecord-1.csv'

df=pd.read_csv("/FileStore/tables/badrecord-1.csv")

Error: FileNotFoundError: [Errno 2] No such file or directory: '/FileStore/tables/badrecord-1.csv'

Anyone, please tell me how to resolve the above error. thanks

2 REPLIES 2

Anonymous
Not applicable

So pandas runs on the driver and will read from the driver's filesystem. DBFS is the distributed file system. You can use %sh fs ls to explore the files on the driver.

tinendra
New Contributor III

dbutils.fs.ls("/FileStore/tables/badrecord-1.csv")

the above file is there in that particular location but still getting the same error

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group