I have a Google Spreadsheet that receives data from a Quickbooks invoice entry. The data from item description has the quantity of each item separated by commas, then the items which are also separated by commas. Quantity and items are separated by a ~
. Quickbooks always sends a "None" to indicate the end of the list for each. I need to split the data, match the quantity to the items, add new rows and replicate the data in the other columns for however many are in the list from Quickbooks. I have found script to split comma separated data into new rows but not for the combining. Any suggestions?
Google-sheets – How to split then combine data to rows
google sheets
Related Topic
- Google-sheets – How to split and transpose text in cells from multiple rows into 1 column
- Google-sheets – Split Google Sheet into new Google Sheets by row key
- Google-sheets – Add row instead of overwriting cells with IMPORTRANGE
- Google-sheets – Split multiple line cells from various column and duplicate the surrounding rows
- Google-sheets – Auto Decrease Based on [tags:CheckBox] from Another Tab (or Alternatively Another Cell on Same Sheet)
Best Answer
It seems you want the processed entries (the row with ~) to remain in the spreadsheet. In this case it's reasonable to have some indicator of whether the row has been processed by the script, so it doesn't add the same things again. Something like this:
And here is a script that handles it. Standard JavaScript string methods: split, indexOf, and concatenation.
Output:
In this example there is no separation between old and new format, because
appendRow
puts a row directly under the existing data. But if you put something like "new format" at the bottom of spreadsheet, it will be appended after it.But it's probably better to put the exported data on another sheet, so that the existing one can still receive new entries without messing things up. E.g., add
at the beginning, and then use
targetSheet.appendRow(...
instead ofsheet.appendRow(...
.