import gspread from oauth2client.service_account import ServiceAccountCredentials from datetime import date def upload_stat_data_to_google_sheets(email, posts_in_queue, followers): scope = ["https://spreadsheets.google.com/feeds", 'https://www.googleapis.com/auth/spreadsheets', "https://www.googleapis.com/auth/drive.file", "https://www.googleapis.com/auth/drive"] creds = ServiceAccountCredentials.from_json_keyfile_name( os.path.join(os.getcwd(), 'stat_scraper',"google_cloud_credentials.json"), scope) client = gspread.authorize(creds) sheet = client.open("automation_stats").sheet1 analytics = client.open("automation_stats").worksheet("analytics") data = sheet.get_all_records() current_date = date.today().strftime('%d.%m.%y') row_to_insert = [[current_date, email, posts_in_queue, followers]] sheet.append_rows(row_to_insert)
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter