I need an API that could help me retrieve the data from Google Sheets, so I tried GSpread for retrieving 3000+ rows from a single worksheet, and it took me several minutes to wait for the data to be printed. However, there are some instances that even though I waited for more than 10 minutes, the data is still not showing. And the weird part is after 10 minutes, when I tried interrupting the program by clicking Ctrl+C, the process ends without any errors and printed the complete data. I also tried interrupting the program 1 minute after running the program but it showed some error messages and did not showed any data.
Is it a bug in GSpread or a normal thing for retrieving thousands of rows in Google Sheets? How could the program automatically end by itself after the retrieving of data finishes?
Here is my code (I just followed the documentation):
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ['https://spreadsheets.google.com/feeds']
creds = ServiceAccountCredentials.from_json_keyfile_name('client_secret.json', scope)
client = gspread.authorize(creds)
sheet = client.open('Sample Sheet').worksheet('First Worksheet')
data = sheet.get_all_records()
print(data)
And since I am retrieving more than thousand lines of code, are there any alternatives that is better and more efficient than GSpread API which is also faster when retrieving data from Google Sheets to Python? Since I don't want to wait for the data to be retrieved for more than 10 minutes.
Thanks in advance!