burnash/gspread — pull request #24 by candeira (2012-04-14 18:47:47+00:00)
Title: Worksheet.get_all_values does not represent sparse regions adequately

I used Worksheet.get_all_values to import a worksheet, and then tried to turn each row into a dictionary, using the first row as a list of keys. This is my code:

data = sheet.get_all_values()
keys = data[0]
del data[0]
students = {}
for row in data:
student = dict(zip(wks_keys,row))
students[student["Email"]] = student

The problem was that get_all_values() returned lists of different length if there are blank cells interspersed with filled cells, so the list values returned do not line up with the keys in the first row in the same way they line up in the spreadsheet.

Last commit is the fix, previous commit contains a new test that highlights the issue.

I don't think the new behaviour should break anyone's code relying on the old behaviour. Probably the old behaviour has either been unnoticed, or fixed by adding nonblank values to blank cells before reading them.