cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
cancel
Showing results for 
Search instead for 
Did you mean: 

i am trying to read csv file using databricks, i am getting error like ......FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/tables/world_bank.csv'

Venky
New Contributor III

i am trying to read csv file using databricks, i am getting error like ......FileNotFoundError: [Errno 2] No such file or directory: '/dbfs/FileStore/tables/world_bank.csv'

image

1 ACCEPTED SOLUTION

Accepted Solutions

Alexis
New Contributor III

Hi

you can try:

my_df = spark.read.format("csv")

      .option("inferSchema","true")  # to get the types from your data

      .option("sep",",")            # if your file is using "," as separator

      .option("header","true")       # if your file have the header in the first row

      .load("/FileStore/tables/CREDIT_1.CSV")

display(my_df)

from above you can see that my_df is a spark dataframe and from there you can start with you code.

View solution in original post

19 REPLIES 19

-werners-
Esteemed Contributor III

This means the path to the file you typed is not valid, the file is not there.

Can you check in the Data/DBFS page if the file is there (or via dbutils.fs.ls)?

Venky
New Contributor III

No, file path is correct

image

Kaniz
Community Manager
Community Manager

Hi @Venky D​ ,

Given that the file path is correct, the code runs well.

Screenshot 2021-10-26 at 7.15.37 PM

Kaniz
Community Manager
Community Manager

Hi @Venky D​ , Were you able to read your CSV file using databricks?

KumarPalle
New Contributor III

I am wondering how it worked for you. I have tried the same steps and no

luck. using dbutils i am finding file but when i read using pandas its saying no such file or directory exists.

dbutils.fs.ls("FileStore/shared_uploads/kumarpalle/Covid19Europedata.csv")

image 

Please help here. uploaded the same file that am working on.

Also, please check if you have applied any settings that we are missing.

Alexis
New Contributor III

Hi Kumar,

you're almost there, try this:

df1 = pd.read_csv("/dbfs/FileStore/shared_uploads/kumarpalle/Covid19Europedata.csv")

df1.describe()

Cheers!

KumarPalle
New Contributor III

Hi @Alexis​ ,

Thanks for quick response. It above method didn't worked but reading using spark and appending to Pandas it worked.

Here are the steps that i followed.

df1 = spark.read.format("csv").option("header", "true").load("dbfs:/FileStore/shared_uploads/kumarpalle/Covid19Europedata-1.csv").toPandas()

df1.head()

image 

KumarPalle
New Contributor III

@Venky D​ Please follow the above steps to read using Spark as pandas doesn't work through dbfs.  

same issue here... .toPandas() was also my only solution... otherwise error!

SanchesSan
New Contributor II

I did the same as you, but the reading does not work.

SanchesSan_0-1693410377818.png

Can you help me? thanks

 

Venky
New Contributor III

Please help me on this error

-werners-
Esteemed Contributor III

can you try without the dbfs part?

so /Filestore/tables/world_bank.csv

Venky
New Contributor III

it's not working

Kaniz
Community Manager
Community Manager

Hi @Venky D​ , Is it working now?

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.