Csv row to google sheet with apps script


issue with :
var data2 = eval("["+ e.parameters.csvdata1 +"]");

issue with :

var data2 = eval("["+ e.parameters.csvdata1 +"]");

in a post https://sites.google.com/view/metricrat-ai2/guides/export-csv-data-multiple-data-to-google-sheetI found this instruction line that allowed me to convert a csv format line to a table
it worked.
a few weeks later I use this same instruction it works randomly
what can explain this? an evolution of script apps?
however I tested the script without the application and everything suggests that it comes from the application and yet I have verified that I am sending the data

maybe there are other ways of doing this ...

Try with json.parse:

var data2 = JSON.parse(e.parameter.csvdata1);

from the data I send, i.e. lists that have been transformed into csv line
I tried without the application this
var data2 = JSON.parse("dog","mouse","cat","house")

it doesn't work

Perhaps like this (in google apps script):

var data2 = JSON.parse(JSON.stringify(["dog","mouse","cat","house"]));

data[0] returns dog, data[1] returns mouse, etc.

i tried this :

var u = e.parameters.csvm ;

var data2 = JSON.parse(JSON.stringify([u]));

before i have tried ;

var data2 = JSON.parse(JSON.stringify([e.parameters.csvm]));

it doesn't work

Did you try it without the square brackets > [ ] ?

What "exactly" is in your e.parameters.csvm? > what are you sending?

Are you using POST or GET ?

yes i tried without and i get an error

i'm sending csv row like : "dog","mouse","cat","house"

i use post and get as it often advised

This works with POST:

function doPost(e) {

var data = e.postData.contents.split(",") ;

var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('Sheet1');


return ContentService.createTextOutput(data) ;





I will try but I am in doubt, will it also work if my data looks like an array or list of list ?

volvo, green,10000
ford, red, 18000
toyota, blue, 14000

In that case I would do it like this:

Convert the csv table string to a list, and then POST the list.

function doPost(e) {

var data = JSON.parse(e.postData.contents) ;

var ss = SpreadsheetApp.getActive();
var sh = ss.getSheetByName('Sheet1');

for (var i=0;i<data.length;i++) {

return ContentService.createTextOutput("Success") ;



Export CSV data (multiple data) to Google Sheet

1 Like


thanks for your answer
i tried this but it doesn't work
do you use apps script ?
in my script JSON isn't blue

Yes, using google apps script
Check your script syntax and your csv table data input

for now I only use the script and the blocks given as an example without the app

So you are using Postman or curl for the POST request ? You cannot run a POST request in the browser.

not at all
for the moment I especially check that the scripts work and the solutions that I find that and where I am offered generally work without problem
that's why I'm going to review this solution that worked so well a few weeks ago

var data2 = eval("["+ e.parameters.csvdata1 +"]");Blockquote

no this instruction is not obsolete
I do not create my lists like in the post and I made the fatal mistake of using block like this

with this one below it works

thank you for your support Tim

This is exactly why we ask people to show their relevant blocks :weary:

1 Like