Created
July 10, 2020 21:25
-
-
Save sebastianmurillonader/b7fd84a0935e0ca1b6f78b35800b1d57 to your computer and use it in GitHub Desktop.
Revisions
-
sebastianmurillonader created this gist
Jul 10, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ #Define scope of API. scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] credentials = ServiceAccountCredentials.from_json_keyfile_name('./insertNameOfYourKeyFile.json', scope) #Get this file by activating the Google Sheets API from your Google account. gc = gspread.authorize(credentials) #Define spreadsheet variables. spreadsheetKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' book = gc.open_by_key(spreadsheetKey) worksheet = book.worksheet("hoja1") table = worksheet.get_all_values() #Convert table data into a dataframe df = pd.DataFrame(table[1:], columns=table[0]) #Convert number strings to floats and ints df = df.apply(pd.to_numeric, errors='ignore') #Print first 5 rows. df.head()