-1

I have a question that is , how to read rows which have data ? Rows are empty i dont want to read them. Otherwise , i want to.

Here is my code:

from queue import Empty
import gspread
from oauth2client.service_account import ServiceAccountCredentials

scopes = [
    'https://www.googleapis.com/auth/spreadsheets',
    'https://www.googleapis.com/auth/drive'
]

cred = ServiceAccountCredentials.from_json_keyfile_name("C:/Users/dell/OneDrive - khang06/My-Workspace/Programming/CLB-Stem-TamPhu/EmailSender/my_key.json" , scopes=scopes)

file = gspread.authorize(cred)
workbook = file.open("Application_to_Tam_Phu_Stem_Club")

sheet = workbook.worksheet("Responses")

Hopefully , i can be helped. Thanks a lot

Kos
  • 4,890
  • 9
  • 38
  • 42

1 Answers1

0

Hi unfortunately if you don't know which row has data and which row doesn't before you run your code, that won't be possible.

Basically you have 2 options:

  1. You already know that, let say the first 10 rows contain data, so you only read the first 10 rows ( which does not seem to be your case)
  2. You read the entire sheet or one row at the time and you check what is in it. You can't ask gspread or Google spreadsheet to return only rows with data.
Lavigne958
  • 442
  • 5
  • 12