cancel
Showing results for 
Search instead for 
Did you mean: 
Community Discussions
cancel
Showing results for 
Search instead for 
Did you mean: 

issue when reading csv in pandas

sbs
New Contributor II

 

Hello Team,

I've encountered an issue while attempting to read a CSV data file into a pandas DataFrame by uploading it into DBFS in the community version of Databricks. Below is the error I encountered along with the code snippet I used:

import pandas as pd

df1 = pd.read_csv("/dbfs/FileStore/shared_uploads/shiv/Dea.csv")

Error Encountered:
FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/shared_uploads/shared_uploads/shiv/Dea.csv'

However, when checking for the file using the dbutils.fs.ls command, I can see the file present:

dbutils.fs.ls("/FileStore/shared_uploads/shiv/Dea.csv")

Output:

[FileInfo(path='dbfs:/FileStore/shared_uploads/shiv/Dea.csv', name='Dea.csv', size=18679559, modificationTime=1711631849000)]

3 REPLIES 3

Lakshay
Esteemed Contributor
Esteemed Contributor

Are you able to read file from that location using spark code?

 

sbs
New Contributor II

yes 

 

YuliyanBogdanov
New Contributor III

Assuming dbutils.fs.ls works without the "dbfs:/" prefix, try using it directly, i.e. df1 = pd.read_csv("/FileStore/shared_uploads/shiv/Dea.csv") . Alternatively, adjust the path as needed if using a local file path df1 = pd.read_csv("dbfs:/FileStore/shared_uploads/shiv/Dea.csv"). Hope that helps.

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.