Skip to content
Advertisement

Unable to insert 2d array within gspread

I’m trying to insert a 2D array in order to get two columns inserted into a sheet via gspread. I’m able to insert the individual lists fine, but inserting the array causes an error. Here’s my code.

JavaScript

Here’s the value of rows

[[['$81.57'], ['$80.91'], ['$91.63'], ['$91.63'], ['$455.20'], ['$196.90'], ['$282.60'], ['$146.10'], ['$97.22'], ['$166.70'], ['$287.30'], ['$237.50']], ['781411', '781415', '781412', '781416', '701355', '701330', '701346', '701352', '782153', '701354', '781347', '781345']]

And here’s the error I get

JavaScript

Advertisement

Answer

I believe your goal as follows.

  • From the following sample value.

    Here’s the value of rows

    [[['$81.57'], ['$80.91'], ['$91.63'], ['$91.63'], ['$455.20'], ['$196.90'], ['$282.60'], ['$146.10'], ['$97.22'], ['$166.70'], ['$287.30'], ['$237.50']], ['781411', '781415', '781412', '781416', '701355', '701330', '701346', '701352', '782153', '701354', '781347', '781345']]

  • I understood that the values of priceList and skuList might be the following values.

    JavaScript
  • You want to put the values of priceList and skuList to 2 columns.

Modification points:

  • In this case, the array is required to be as follows.

    JavaScript
  • When you want to insert the several rows with 2 columns, you can use insert_rows().

When this is reflected to your script, it becomes as follows.

Sample script:

JavaScript
  • When you run this script, the values of priceList and skuList are put to the columns “A” and “B” of “Sheet1”.

References:

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement