Home > Enterprise >  how do I convert [1,2,3] to [[1],[2],[3]]?
how do I convert [1,2,3] to [[1],[2],[3]]?

Time:11-24

I am working google sheets and need to update a column.

val = [1,2,3,4,5,6,7,8,9] 
worksheet.update('A2:A10', [val])

Just doing this throws an error, which I feel means that it is trying to update rows instead of column.

gspread.exceptions.APIError: {'code': 400, 'message': 'Requested writing within range [Sheet1!D2:D38], but tried writing to column [E]', 'status': 'INVALID_ARGUMENT'}

CodePudding user response:

If the problem is as you stated in the question title, you need:

worksheet.update('A2:A10', [[i] for i in val])
  • Related