如何在Google Sheets中利用单个单元格内的CSV数据生成含所有变体的新数组/行集
Split Comma-Separated Parameters into Paired Rows (Google Sheets)
Got it, you’re so close with your existing attempts—let’s wrap this up. Here’s the exact formula that will generate the full set of name-parameter rows you need:
=ARRAYFORMULA(SPLIT(FLATTEN(A3:A & "|" & SPLIT(B3:B, ", ")), "|"))
Let’s break down why this works (and fix your earlier attempts):
- Your first formula tried pairing
A3:Awith split parameters, but failed becauseSPLITcreates variable horizontal columns that don’t align cleanly with the singleA3:Acolumn. - Your
FLATTENattempt was on the right track, but you needed to first tie each name to its individual parameters before flattening everything into rows.
Here’s the step-by-step logic:
SPLIT(B3:B, ", "): Splits each comma-separated parameter list into separate horizontal cells.A3:A & "|" & ...: Concatenates each name with its corresponding split parameter using a unique delimiter (we picked|here—just ensure it doesn’t appear in your actual data).FLATTEN(...): Turns all those concatenated name-parameter strings into a single vertical list, so each pair becomes a standalone row.SPLIT(..., "|"): Splits each concatenated string back into two columns (Name and Parameters), giving you the exact output you want.
Example Output (matching your desired result):
| Name | Parameters |
|---|---|
| Co1 | Param1 |
| Co2 | Param2 |
| Co2 | Param3 |
| Co3 | Param3 |
| Co4 | Param2 |
| Co4 | Param1 |
If you need to handle empty parameter cells to avoid blank rows, use this adjusted version:
=ARRAYFORMULA(IFERROR(SPLIT(FLATTEN(IF(B3:B<>"", A3:A & "|" & SPLIT(B3:B, ", "),)), "|")))
内容的提问来源于stack exchange,提问作者Prophet
相关产品推荐
相关产品推荐

