Can't pull values from dataframe with df.iterrows?

79 Views Asked by At

I am using gspread to automate a data entry aspect of my job. Is there any way to pass values from df.iterrows to spreadsheet.values_append?

'Key' looks like:

('Saddle Soap 2.8 oz', 'B01NBEGPNF') ('Bick 4 8oz', 'B001CS2Q4M') ('Saddle Soap 6.5', 'B016DQQYVI')

I am trying to loop through each product with it's corresponding id.


key = pd.read_csv('/Users/macbook/Documents/AtomProjects/Sheets1/AutoKey.csv')



#Inputs and file read
print('Date?')
datecolumn = input()
print('Report Path?')
reportpath = input()
df = pd.read_csv(reportpath).drop(columns=['(Parent) ASIN','Title','SKU']) #, index_col = '(Child) ASIN')
#dateinsert
df.insert(0, 'Date', datecolumn)


for index, row in key.iterrows():
    spreadsheet.values_append('Product', params={'valueInputOption':'USER_ENTERED'}, body={'values': df[(df['(Child) ASIN'] == 'Child')].values.tolist()})

Error: Traceback (most recent call last): File "/Users/macbook/Documents/AtomProjects/Sheets1/Ukinv.py", line 34, in spreadsheet.values_append('Product', params={'valueInputOption':'USER_ENTERED'}, body={'values': df[(df['(Child) ASIN'] == 'Child')].values.tolist()}) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/gspread/models.py", line 164, in values_append r = self.client.request('post', url, params=params, json=body) File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/gspread/client.py", line 73, in request raise APIError(response) gspread.exceptions.APIError: {'code': 400, 'message': 'Unable to parse range: Product', 'status': 'INVALID_ARGUMENT'}

Thanks so much for checking it out!

0

There are 0 best solutions below