Embedding a CSV into HTML format is a tedious work unless we have options to use premium built-in connectors.
Herewith is the flow to convert a CSV into HTML format which can be further utilized to Send HTML table in email OR save it as HTML file on Gateway.
Logic of converting CSV to HTML is:
- Get the CSV file content (can be from Onedrive, Sharepoint, on-premise Gateway etc.)
- Read the contents of the file into an array variable EACH_ROW by splitting the contents of CSV data
- Initialize variables for CSS and composing the HTML Table tags with assimilating the EACH_ROW data within CSS and HTML table tags to form HTML table.
- Process the EACH_ROW variable by,
- Replace '\n' value in CSV with '</tr><tr><td>'. This marks the end of each row in CSV data.
- Replace ',' in CSV with '</td><td>'. This marks creating columns for each cell value in CSV data.
- Replace '[' with '<tr><td>'. This marks the header row (1st row) of the CSV data which will be used as header in html table.
- Replace or remove ']' from the CSV data as this appears in trail end of CSV data and is not needed.
- Concatenate the CSS variable with the data obtained in step (d) of Step (4).
- Once the step 'd' from step 4 is obtained,
- Send it in email with CSS applied to it (using step # 3 variables) as specified in step # 5.
- Or embed the table as-is based on your need from Step # 4.
- Or Save it on Gateway (on-premise gateway) accordingly.
CSS that I am applying is - have blue background with white text to header of the table.
Hope this helps! Please feel free to reach out to me in case of any queries or if more details are needed from my side.
Unfortunately I am not able to upload the exact flow, hopefully the screenshots and sample CSV file included in attachments helps you!
If your CSV file differs from the sample, you can still leverage the logic mentioned here by applying the pattern noticed in your CSV file.
Thanks!