Created on 12-30-2019 12:08 AM - last edited on 12-30-2019 12:11 AM by VidyaSargur
Hi All,
I have to display the records of csv file over mail body in tabular format using Putmail.
I am extracting records by executing sql which is scheduled at some duration and than forwarding the same using putmail to some specific users.
Can someone please tell me how to display the data of generated csv file in tabular format.
Created on 12-30-2019 09:50 AM - edited 12-30-2019 09:53 AM
To get it into a table, you need something like this:
<table><tr><td>
${'$1':replace(',','</td><td>'):replace('\n','</td></tr>\n<tr><td>')}
</td></tr></table>
and it should output an HTML Table like this:
<table><tr><td>
Release Cause</td><td>Previous Count</td><td>Current Count</td><td>Change_Ratio</td><td>SEVERITY</td>
</tr><tr><td>SIP: [487] Request Terminated</td><td>173</td><td>393</td><td>1.271676300578034682</td><td>Critical
</td></tr></table>
You may have to play with the last </td></tr> depending on if you have an empty line on bottom or not.
You may also have to adjust \n to \r\n again depending on the source file actual return chars (not seen they are hidden).
Created 12-30-2019 06:30 AM
A replaceText processor can change from Comma Separated to Tab Separated. This would be the easiest option. Configured with [tab] in Search Value, and [,] in Replacement Value:
Created 12-30-2019 07:43 AM
Hi,
I tried doing the same by replacetext but I am getting the output as:
Release Cause,Previous Count,Current Count,Change_Ratio,SEVERITY
test_data,276,730,1.644927536231884058,Critical
but i want the same output in tabular format:
Release Cause | Previous Count | Current Count | Change_Ratio | SEVERITY |
test_data | 276 | 730 | 1.644927536231884058 | Critical |
Please help for the same.
Created on 12-30-2019 08:21 AM - edited 12-30-2019 08:39 AM
If the output is still comma separated, then replace text did not work. The solution above is how you do it. You may need to experiment with other replacements. For example maybe \t instead of [tab]. Again, the method above is what you need.
Here is a similar post that includes some of the other forms of "tab"...
Created 12-30-2019 09:19 AM
Thanks for your help but this is not solving my problem as i want the csv record which itself is in comma separated to be displayed in tabular format as in my mail body through PUTMAIL.
I want records to be displayed in table format rather than comma separated or tab one.
I have comma separated record :
Release Cause,Previous Count,Current Count,Change_Ratio,SEVERITY
SIP: [487] Request Terminated,173,393,1.271676300578034682,Critical
and I want like this in mail body:
Release Cause | Previous Count | Current Count | Change_Ratio | SEVERITY |
test_data | 276 | 730 | 1.644927536231884058 | Critical |
Please suggest a suitable method in order to do the same.
Created on 12-30-2019 09:29 AM - edited 12-30-2019 09:31 AM
I understand you are not able to figure out the exact ReplaceText syntax that you need. I have quickly created a flow and validated the following works as demonstrated. I had to use \t to match your string:
Output:
The regex you need is:
${'$1':replace(',','\t')}
Table formatting is something entirely different and is not part of "csv" parsing....
Created on 12-30-2019 09:50 AM - edited 12-30-2019 09:53 AM
To get it into a table, you need something like this:
<table><tr><td>
${'$1':replace(',','</td><td>'):replace('\n','</td></tr>\n<tr><td>')}
</td></tr></table>
and it should output an HTML Table like this:
<table><tr><td>
Release Cause</td><td>Previous Count</td><td>Current Count</td><td>Change_Ratio</td><td>SEVERITY</td>
</tr><tr><td>SIP: [487] Request Terminated</td><td>173</td><td>393</td><td>1.271676300578034682</td><td>Critical
</td></tr></table>
You may have to play with the last </td></tr> depending on if you have an empty line on bottom or not.
You may also have to adjust \n to \r\n again depending on the source file actual return chars (not seen they are hidden).
Created 12-30-2019 11:39 PM
Thanks Stevenmatison.
It worked!!
Created 12-31-2019 10:49 PM
Hi Steven,
Your solution worked well.
but i have a question related to this topic.
In Putemail, for the solution you provided i am using content type 'text\html' which is delivering result in table format (in mail body) but i am also attaching csv in my mail.
Now this csv is also displaying data with html tag, is it possible to display the data in original form.(only csv format for attachment without html tag).
Created 09-30-2021 12:39 AM
Hello Ashish,
Wanted to check whether you were able to solve this problem. As I have to do something similar. Your help would be appreciated 🙂