Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from __future__ import print_function
- import pickle
- import os.path
- from googleapiclient.discovery import build
- from google_auth_oauthlib.flow import InstalledAppFlow
- from google.auth.transport.requests import Request
- import gspread
- from oauth2client.service_account import ServiceAccountCredentials
- import sys
- from googlesheetsNasserauth import sheetAuth
- #GLOBAL VARIABLES
- GOOGLE_SHEET_API_SCOPE = ['https://www.googleapis.com/auth/spreadsheets']
- SCOPES = ['https://spreadsheets.google.com/feeds',
- 'https://www.googleapis.com/auth/drive']
- #عنوان ال الشيت كله و يكون موجودا في share
- INPUT_SPREAD_SHEET = 'https://docs.google.com/spreadsheets/d/1kIkGpzV0VocwF6msFPL-C8d2zEhJJrQAAx2BG8HIe14/edit?usp=sharing'
- #يمكن اخذه من عنوان الشيت
- INPUT_SPREAD_SHEET_ID = '1kIkGpzV0VocwF6msFPL-C8d2zEhJJrQAAx2BG8HIe14'
- #القيم المطلوبة و تتكون من اسم الشيت + الخلايا المطلوبة
- INPUT_SPREAD_SHEET_RANGE = 'Anime!A2:C9'
- #تفعيل الشيت
- creds = sheetAuth()
- service = build('sheets', 'v4', credentials = creds)
- sheet = service.spreadsheets()
- def updateSheet():
- power_dict = {'lvl0': 100,
- 'lvl1': 200,
- 'lvl2': 250
- }
- values = ['458', 'Hero', 'Gundam Pilot', 90,'lvl0' ]
- spread_sheet = gc.open_by_url(INPUT_SPREAD_SHEET)
- sheet = spread_sheet.worksheet('Anime')
- #This function takes two arguments
- #colors: dictionary contains colors
- #range the cell range to change color
- def getSheetValues():
- result = sheet.values().get(spreadsheetId = INPUT_SPREAD_SHEET_ID, range = INPUT_SPREAD_SHEET_RANGE).execute()
- values = result.get('values', [])
- if not values:
- print('No data found')
- else:
- for row in values:
- print(row)
- if __name__ == '__main__':
- try:
- getSheetValues()
- except:
- print(sys.exc_info()[0:1])
Add Comment
Please, Sign In to add comment