To back up just a bit, my recommendation would be to first try to get the module's example code to run with minimal modifications (I guess you need to add your specific credentials, etc). The author gives a program to generate the credentials and then a program that uses them.
You ask: Can you explain me how to iterate into google sheet, row by row ?. I have no experience with this module, but it appears from your code snippet, that is exactly what this code is doing!
A straightforward reading of the code would indicate that this thing is going row by row, selecting the first cell in each row (row, col),(0,0),(1,0),(2,0), etc. and then writing columns starting in that cell and the to the right of that cell based upon a line in CSV format. The writing of the cells is not done right way, but put into a queue of @requests which are then later processed as a single batch operation.
I presume that $idx is initialized to 0 before this code. coordinate is a reference to a hash with the sheet,x,y coordinates. data => $gs->to_csv(@$row), contains the data for multiple columns, presumably formatted into a single CSV line, by the to_csv method. @$row expands each reference to a row out into each element of the referenced array. (The reference to row is called simply row here, I would have called it $row_ref, but minor quibble)
@rows is an Array of Arrays (a 2-D Array). Each element of @rows is a reference to an array which represents the columns on that particular row. The loop, for my $row (@rows) { will generate one pasteData request per row of data to be written. In this case each request will wind up writing 4 cells on each row, (name age favorite exodus), etc.
So instead of a separate write for each individual cell, this code writes an entire row of 4 columns to the spreadsheet for each request. I presume that is done for efficiency.
I hope this helps you understand what this code appears to do on the surface. Again, I have no experience with this particular module. I just saw that it was available and written years after the one that you were currently using.
We never did figure out why your code that was running "broke". Could be problem with your Perl environment. Could be a problem with something that Google did. I have no idea.
Again, I recommend running the example before trying to modify it for your own purposes.
In reply to Re: Net::Google::Spreadsheets::V4 usage
by Marshall
in thread Net::Google::Spreadsheets::V4 usage
by xodus_fr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |