• Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

JavaScript Mulitple row output array from one row input array??

niceonedelboy

New Coder
Hi,

I asked this before but got now replies - trying again in a more simple form.

I'm a beginner to coding and I'm trying to absorb as much as I can on youtube. I'm coding in AppScripts (javascript I think) for Google Sheets.

I would like to Input one row of data. The output I want is multiple rows of data with new columns.

Eg. if I put in
Date/Category/Amount

I'd like to output multiple rows like

Date/CategoryA/AmontA
Date/Category B/AmountB ....

The output data would depend on rules based on the input Category.

The bit I can't find any help on is how to get an output of multiple rows in an array, based on the input of one row of an array.

Can anyone guide me to the right operator that I can learn?

Thanks,
 
It's been a long time since I worked with google sheets so this might be wrong or out of date.
When you call your apps function you pass it the cell number of CategoryA. This lets you calculate the next row and cell number of where you want your new row. Then if you write three comma-separated amounts it should write three cells. You now can calc the next cell where info will be posted.

sheet.appendRow([1,2,3]) should also work, but it may mess up the sheet. Like I said it's been ages and I don't want to play with sheets right now.

Let me know what kind of luck you're having.
 
It's been a long time since I worked with google sheets so this might be wrong or out of date.
When you call your apps function you pass it the cell number of CategoryA. This lets you calculate the next row and cell number of where you want your new row. Then if you write three comma-separated amounts it should write three cells. You now can calc the next cell where info will be posted.

sheet.appendRow([1,2,3]) should also work, but it may mess up the sheet. Like I said it's been ages and I don't want to play with sheets right now.

Let me know what kind of luck you're having.
Thanks @OldMan , really appreciate the reply. Would your first suggest only work if I wanted to place output rows in a particular row? What I'll need is two arrays, one where all the input rows go, and the second will be a much bigger array based on the input array. So each time I run the app (hopefully I'll find a way to only run it for new data I add); the output array will grow and if I write it to googlesheets it will just appear as long as it is, as oppose to specifying exactly where to write it to.

does that make sense?

I was hoping that this array manipulation wouldn't be specific to google sheets and that it would be a standard activity in javascript. Google Sheets is an arbitrary place to write the new array.
 
Are you asking if JS can store a large amount of data for you that will grow and/or change over time?
If yes then yes you can. And you can use that data and show it in a browser or in google sheets.
It can be done on your computer or on the web. I do mine on the web.
 
Top Bottom