Aug-04-2020, 06:58 AM
Hi!
I am using some salesforce script to get gsheet data and insert it into salesforce.
My problem is how to proper iterate through my cells.
Im connecting with gspread.
My idea is to create simple loop, sth like this:
I am using some salesforce script to get gsheet data and insert it into salesforce.
My problem is how to proper iterate through my cells.
Im connecting with gspread.
# Authorise your Notebook gc = gspread.authorize(credentials) # The sprad sheet ID, which can be taken from the link to the sheet spreadsheet_key = 'xxx' sheet = gc.open_by_url('https://docs.google.com/spreadsheets/d/url') worksheet = sheet.get_worksheet(1) data = worksheet.get_all_values() headers = data.pop(0) df = pd.DataFrame(data, columns=headers)Frame has 48 columns. I want to prepare a function which inserts values from column nr 44 and column nr 30. I have for my tests 10 rows.
My idea is to create simple loop, sth like this:
#for c in range(worksheet.ncols): # for r in range(worksheet.nrows): for c in range(ncol?): for r in range(nrow?): Subject = 'test subject' Type: 'Note' Description = worksheet.ol_values(2,r)[0] --I have no idea here, need to use column nr 30 print(Description) Owner = worksheet.ol_values(2,r)[0] -- I have no idea here, need to use column nr 44 print(Owner) --sf insert function--Any help appreciated! I'm using gsheets for the first time.