Google Spreadsheet в CSV на Google Диске - PullRequest
       12

Google Spreadsheet в CSV на Google Диске

0 голосов
/ 26 сентября 2019

При загрузке CSV-файла на диск Google он автоматически конвертируется в Google Sheets.Как сохранить его в виде файла CSV на диске?или я могу прочитать лист Google через фрейм данных pandas?

Среда разработки: Google Colab

Фрагмент кода :

Ввод

data = pd.read_csv("ner_dataset.desktop (3dec943a)", 
encoding="latin1").fillna(method="ffill")

data.tail(10)

Выход

    [Desktop Entry]
0   Type=Link
1   Name=ner_dataset
2   URL=https://docs.google.com/spreadsheets/d/1w0...

Ответы [ 2 ]

0 голосов
/ 26 сентября 2019

РАБОЧИЙ КОД

from google.colab import auth
auth.authenticate_user()

import gspread
from oauth2client.client import GoogleCredentials

gc = gspread.authorize(GoogleCredentials.get_application_default())

worksheet = gc.open('Your spreadsheet name').sheet1

# get_all_values gives a list of rows.
rows = worksheet.get_all_values()
print(rows)

# Convert to a DataFrame and render.
import pandas as pd

pd.DataFrame.from_records(rows)
0 голосов
/ 26 сентября 2019
#Mount the Drive
from google.colab import drive
drive.mount('drive')

#Authenticate you need to do with your credentials, fill yourself
gauth = GoogleAuth()

#Create CSV and Copy
df.to_csv('data.csv')
!cp data.csv drive/'your drive'
...