#!/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

def save_sheet(df,filename,tabname,startpos='A1'):

    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)
    spread = Spread(filename,creds=credentials)

    spread.df_to_sheet(df, index=False, sheet=tabname, start=startpos, replace=False)

def get_sheets(filename):

    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)
#    files=gc.list_spreadsheet_files()
#    print(files)
    spread = Spread(filename,creds=credentials)
    for ws in spread.sheets:
        print(ws.title)

get_sheets('designer_ranking')
#    spread.df_to_sheet(df, index=False, sheet=tabname, start=startpos, replace=False)
#
