gspreadsheet.md 826 B

Google Spreadsheet

#!/usr/bin/python3
import sys
import codecs
import traceback
import requests
import re
import pandas as pd
import random
import urllib
import json
import gspread
import datetime
from gspread_pandas import Spread, Client
from oauth2client.service_account import ServiceAccountCredentials
import os

df = pd.DataFrame(columns=('F1','F2'))
df.loc[0]=['中文','測試']
df.loc[1]=['English','Test']

scope = ['https://spreadsheets.google.com/feeds',
        'https://www.googleapis.com/auth/drive']

credentials = ServiceAccountCredentials.from_json_keyfile_name('c:\\keys\\service\\gspread.json', scope)
gc = gspread.authorize(credentials)
start='A1', replace=False)
spread = Spread('S1',creds=credentials)

spread.df_to_sheet(df, index=False, sheet='test_spreadsheet', start='A1', replace=False)