Created
July 10, 2020 21:25
-
-
Save sebastianmurillonader/b7fd84a0935e0ca1b6f78b35800b1d57 to your computer and use it in GitHub Desktop.
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 characters
#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() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment