This is what the product details for one of our products look like and is formatted before we import it into Shopify to be shown on our e-com store:
<ul>
<li>Comfort: waterproof, windproof, lightweight, engineered ventilation</li>
<li>Material: 100% polyester with polyurethane coating</li>
<li>Water column pressure: 4000mm</li>
<li>Fit: Casual unisex</li>
<li>Snap closure</li>
<li>Placket with snap fastenings</li>
<li>Drawstring hood with cap brim</li>
<li>Snap adjustable cuffs</li>
<li>Back yoke with concealed vents</li>
<li>Two side pockets with snaps</li>
<li>Eyelets at arm holes</li>
<li>Ultrasonically welded seams</li>
<li>Fishtail hem</li>
</ul>
What I would like to achieve is to convert that ^ into this:
<table>
<tr>
<td>Comfort:</td>
<td>waterproof, windproof, lightweight, engineered ventilation</td>
</tr>
<tr>
<td>Material:</td>
<td>100% polyester with polyurethane coating</td>
</tr>
<tr>
<td>Water column pressure:</td>
<td>4000mm</td>
</tr>
<tr>
<td>Fit:</td>
<td>Casual unisex</td>
</tr>
</table>
<ul>
<li>Snap closure</li>
<li>Placket with snap fastenings</li>
<li>Drawstring hood with cap brim</li>
<li>Snap adjustable cuffs</li>
<li>Back yoke with concealed vents</li>
<li>Two side pockets with snaps</li>
<li>Eyelets at arm holes</li>
<li>Ultrasonically welded seams</li>
<li>Fishtail hem</li>
</ul>
The logic behind it: All lines that has a colon should be in a table format. The rest should be in a list format.
When the line has a colon, it should be split into two different columns inside the table. For example, <li>Material: 100% polyester with polyurethane coating</li>
is turned into
<tr>
<td>Material:</td>
<td>100% polyester with polyurethane coating</td>
</tr>
Can this be automatically done in Google Sheets where each cell contain product details for one product.
Thanks!
2
Answers
Description
Using App script the following example script will take each row and convert any rows that contain
:
into a table. The end result of this scipt is a single string of all the and linesCode.gs
Execution log
Try