Google Sheets API Error

Frank Pinto fapb88ve at gmail.com
Fri Jun 16 18:32:36 EDT 2017


Hello,

I'm building an app that needs to do the following things: a) checks a
Google Sheet for email and name of a client, b) logs into a dropbox account
and downloads some files (only those files with the name from the google
sheet), c) does some work on the files d) sends the new files to the
clients with the information from the google sheets. It needs to do this
from the first moment it runs till 7:30 PM local time (using a while loop).

The problem I'm having is that when it starts running, the first iteration
runs fine. When it gets to the second, the google sheets function I created
that accesses the data of the sheets does not work (even though it did the
first time). The console yields the following error:

"FileNotFoundError: [Errno 2] No such file or directory: 'client_id.json'"

This is weird, because the json file obviously is not moved in between
runs. Here's an overview of the structure of the code:

def full():
global logo, plogo, plogow, plogoh, client, metadata, logo_path
inst = 1
logo_path = os.path.abspath('.\\logo\\p4.png')
client = dropbox.client.DropboxClient(XXXXX')
while datetime.datetime.now().time() <= datetime.time(19, 45):
if inst == 1:
custo = customers()
if len(custo) == 0:
pass
else:
metadata = client.metadata('/')
d_files = files()
send_f = pd.merge(d_files, custo, left_on='c_name', right_on='Nombre',
                              how='inner')
dl_files(send_f, custo)
else:
temp = customers()
send = temp[~temp.isin(custo)].dropna()
custo = customers()
if len(send) == 0:
pass
else:
metadata = client.metadata('/')
d_files = files()
send_f = pd.merge(d_files, custo, left_on='c_name', right_on='Nombre',
                              how='inner')
dl_files(send_f, send)
time.sleep(30)
inst += 1

The  'customers()' function that is giving me problems:

def customers():
    scope = ['https://spreadsheets.google.com/feeds']
    creds =
ServiceAccountCredentials.from_json_keyfile_name('client_id.json', scope)
    client = gspread.authorize(creds)

    sheet = client.open('RC').sheet1
    c_list = sheet.get_all_records()
    df = pd.DataFrame(c_list)
    return df

I really have no idea why this is happening. Does anybody might have a clue?

Thank you,




-- 
Frank Pinto



More information about the Python-list mailing list