Your Name %!s(int64=4) %!d(string=hai) anos
pai
achega
7607e532b6
Modificáronse 2 ficheiros con 35 adicións e 0 borrados
  1. 1 0
      README.md
  2. 34 0
      dev/gspreadsheet.md

+ 1 - 0
README.md

@@ -18,6 +18,7 @@
 * [NetworkX](/dev/networkx.md)
 * [rpyc](/dev/rpyc.md)
 * [selenium](/dev/selenium.md)
+* [Google Spreadsheet](/dev/gspreadsheet.md)
   
 ## Windows Environment
 

+ 34 - 0
dev/gspreadsheet.md

@@ -0,0 +1,34 @@
+# 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)
+
+```