0

I'm a beginner in programming, and I'm trying to print a nested array to a sheet. sourceData is an array that has 252 other arrays inside it and each one of these arrays has 10 element, so i want to print these 10 elements in 10 column (each element in its own cell) in one row 252 times. I tried doing that using a for loop but it was getting the first element only "370" in all the columns + in 502 rows and i feel like its very messy.

var y=0;
  for(let x=3; x<sourceData.length+3; x++){//   x is number of the row


  
  thisSheet.getRange(parseInt(x),1 ,sourceData.length,10).setValue(sourceData[y]);
  y++;
  }

If you need more information please let me know.

I have been stuck here for too long and would really appreciate the help.

Thank you.

2
  • stackoverflow.com/questions/14037540/… You should be able to import csv into excel. Commented Feb 2, 2022 at 16:19
  • But im using java script not python Commented Feb 2, 2022 at 16:22

1 Answer 1

3

You shouldn't need a loop.

Try

thisSheet.getRange(3, 1, sourceData.length, sourceData[0].length).setValues(sourceData)
Sign up to request clarification or add additional context in comments.

1 Comment

Oh that worked. thank you so much

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.