Pattern: Convert HTML Table to Catalytic Data Table
Thomas_937381
Posts: 196
If you have (HTML) tables contained in the body of an email message that need to be in .xlsx, .csv, or table format, the attached pattern will allow you to do so.
One of the fields from an email trigger is html. With this, we:
- Use Text: Find text next to other text to parse the portion of the HTML containing a table
- Remove line breaks, then commas (which will act as our delimiter)
- Replace the
</td>
tag with commas - Replace the
<tr>
tag with a line break (\n), and remove the remaining HTML with the below formula:
result = fields['your-field'].replace(/\<tr(.*?)\>/g,'\n').replace(/<(?:.|\n)*?>/gm,'')
With a few small additional modifications to the text, we can create a clean data table, which can subsequently be filtered, summarize, or transformed as you require.
Tagged:
0
Comments
-
I forgot to add that the table being embedded in the email for this test has just two columns, and looks like this:
Item Value 123 $500 456 $400 789 $300 0