Reputation: 1825
How can I access the files on the left bar of Google Colab? By default sample data is given, when I run !ls sample_data
command it lists the files as it should:
anscombe.json mnist_test.csv
california_housing_test.csv mnist_train_small.csv
california_housing_train.csv README.md
But when I run following code:
import pandas as pd
data = pd.read_csv('content/sample_data/mnist_test.csv')
print(data.head())
I get an error: FileNotFoundError
Upvotes: 3
Views: 20100
Reputation: 319
The directory is not in G-Drive, it is VM of colab.
So the 'sample_data/'
directory path is './sample_data/'
You should change the path, then O.K.
import pandas as pd
data = pd.read_csv('./sample_data/mnist_test.csv')
print(data.head())
Good luck!
Upvotes: 1
Reputation: 523
July 2020
I see you just missing / before dir
import pandas as pd
#data = pd.read_csv('content/sample_data/mnist_test.csv')
# this is corrct one
data = pd.read_csv('/content/sample_data/mnist_test.csv')
print(data.head())
Upvotes: 1
Reputation: 1076
using upload will place the files under / if you dont move them, so try /PetImages/Dogs/, alternatively you can upload them to google drive and mount your google drive giving access to your files in colab running this in a cell
from google.colab import drive
drive.mount('/content/drive')
copy over the folder to /content/ using
!cp /content/drive/My\ Drive/PetImages.zip /content/
then use !unzip PetImages.zip
now your directory will be /content/PetImages/Dogs/ which might be easier as uploading directory to colab is slower and gets deleted after 12 hours.
Upvotes: 7
Reputation: 1
Are you able to list those files with the command !ls ? Have you already mounted your google drive to colab to access those files? if not, please do so by following the commands mentioned in this blog post
Upvotes: 0