Import CSV files from Drive into Google Collab

Asked

Viewed 343 times

0

Good afternoon, I’m having trouble importing the files in csv to the collab. Keeps popping up the same error message that my files cannot be located in the folder I specified (and they are there)

I was able to import as a test only the: SGL_ESTADOS

I don’t know if the file size influence in this case, working on my PC, I was able to quietly import all the datasets in Jupyter.


  • Executed commands
import pandas as pd
from google.colab import drive
drive.mount('/content/drive')
import os
os.getcwd()
# Importanto data frame - Colab
DM_ALUNOS = pd.read_csv (r'drive/My Drive/Path/Path/DM_ALUNO.csv',
                 skiprows=sorted(random.sample(range(1,n),n-s)),
                 delimiter='|',
                 encoding='latin1', 
                 )

DM_CURSOS = pd.read_csv(r"drive/My Drive/My Drive/[Path/Path/DM_CURSO.csv",
                 skiprows=sorted(random.sample(range(1,n),n-s)),
                 delimiter='|',
                 encoding='latin1', 
                 )
    
DM_IES = pd.read_csv(r'drive/My Drive/My Drive/Path/Path/DM_IES.csv',
                 delimiter='|',
                 encoding='latin1'
                 )

SGL_ESTADOS = pd.read_csv(r'drive/My Drive/Path/Path/SGL_ESTADOS.csv',
                 delimiter=';'
                 )

  • Error message when running cell:

Filenotfounderror: [Errno 2] No such file or directory: 'drive/My Drive/Path/Path/DM_ALUNO.csv'


  • Print with the files in the path folder.

Pastas onde estão os cursos

1 answer

1


Add /content/ before drive

from google.colab import drive
drive.mount('/content/drive')

base = pd.read_csv ('/content/drive/My Drive/Path/Path/DM_ALUNO.csv'')
  • continued with the same error: 
[Errno 2] No such file or directory: 'content/drive/My Drive/Path/Path/DM_ALUNO.csv'


  • 1

    Your files really are in these directories (/Path/Path/), by print you can not see?

  • 1

    You also forgot / at first

  • Yes, the SGL_ESTADOS I managed to import, the others did not.

  • Got it, really that was what was missing! But there were some errors (typing) that was on my face and I wasn’t seeing

Browser other questions tagged

You are not signed in. Login or sign up in order to post.