Sorry for my bad coding, I'm pretty new to working with API's. Anyways, I'm trying to get a range of columns from Google Sheets and display them to my console. For example, I want all data from columns A to D and just print them out to console. However, I noticed when using gspread I could only access 1 column at a time.
I would use:
data = workSheet.col_values(2)
and it would only allow me to select the second column. Then I tried:
data = workSheet.col_values(2, 6)
but it would just show me an error.
I was wondering if there was a way to print out a range of columns.
Instead of using col_values()
, try just get()
which allows you to pass a range in A1 notation:
data = workSheet.get('A:D')
https://gspread.readthedocs.io/en/latest/api.html#gspread.models.Worksheet.get