close

How to specify file path in jupyter notebook

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to specify file path in jupyter notebook in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to specify file path in jupyter notebook?

  1. How to specify file path in jupyter notebook?

    I solved this problem by mounting the Google Colab to Google Drive. This is the path after I mount to Google Drive:

  2. specify file path in jupyter notebook

    I solved this problem by mounting the Google Colab to Google Drive. This is the path after I mount to Google Drive:

Method 1

I solved this problem by mounting the Google Colab to Google Drive. This is the path after I mount to Google Drive:

csvFile = '/content/drive/My Drive/Colab Notebooks/myData.csv.txt'
xmlFile = '/content/drive/My Drive/Colab Notebooks/myData.xml'

Method 2

  1. If the author is directly calling the file then it is in the same folder where the Jupyter Notebook is running
  2. One of the following should work to call files from different locations:

a. Replace single quotes with double quotes and escape the slashes ex. csvFile = "C:\\Users\\...\\myData.csv"

b. Replace single quotes with double quotes and use forward slashes ex. csvFile = "C:/Users/.../myData.csv"

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read