“Lea el archivo de Google Drive Colab” Código de respuesta

Descargar Google Drive File Colab

!gdown --id yourFileIdHere
Grieving Grivet

Lea el archivo de Google Drive Colab

from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
Eager Eel

Lea el archivo de Google Drive Colab

downloaded = drive.CreateFile({'id':"your_file_ID"})   # replace the id with id of file you want to access
downloaded.GetContentFile('your_file_name.csv')        # replace the file name with your file
Eager Eel

Lea el archivo de Google Drive Colab

auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
Eager Eel

Lea el archivo de la unidad en Colab

!pip install -U -q PyDrive
import os
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials

# 1. Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)

# choose a local (colab) directory to store the data.
local_download_path = os.path.expanduser('~/data')
try:
  os.makedirs(local_download_path)
except: pass

# 2. Auto-iterate using the query syntax
#    https://developers.google.com/drive/v2/web/search-parameters
file_list = drive.ListFile(
    {'q': "'1SooKSw8M4ACbznKjnNrYvJ5wxuqJ-YCk' in parents"}).GetList()

for f in file_list:
  # 3. Create & download by id.
  print('title: %s, id: %s' % (f['title'], f['id']))
  fname = os.path.join(local_download_path, f['title'])
  print('downloading to {}'.format(fname))
  f_ = drive.CreateFile({'id': f['id']})
  f_.GetContentFile(fname)


with open(fname, 'r') as f:
  print(f.read())
Worrisome Worm

Respuestas similares a “Lea el archivo de Google Drive Colab”

Preguntas similares a “Lea el archivo de Google Drive Colab”

Más respuestas relacionadas con “Lea el archivo de Google Drive Colab” en Python

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código