How to create multiline csv cell through shell script?

Hi,

I have a text like the one given below

status="Observation 1"
read1="Source rows not load"
read2="Score drop"

I want to create a csv and mail it out in such a way that all three lines will be in a single cell but as three lines.

For ex

                    Col C1
 
                Observation 1
Row R1       Source Rows not load
                 Score drop

I tried multiple ways But I always end up in getting all three messages in a single line or three different rows.

Any suggestions?

I don't think you can do this kind of formatting in CSV. I would suggest to create a HTML table out of your file data using awk with formatting of your choice.

Here is an example:

awk -F= ' BEGIN {
                print "<html><body>"
                print "<table border=1>"
                print "<tr><td align=center>"
        } {
                gsub(/"/,X);
                print $2"<br>";
        } END {
                print "</td></tr>"
                print "</table>"
                print "</body></html>"
} ' file

If your loading the file from Excel your required format is:

"Observation 1
Source Rows not load
Score drop"^M

Where ^M is above is AscII 13 (\r)

this awk script should produce what you want:

awk -F\" '
/^status=/ { $2="\" $2}
/^read2=/ {$2=$2 "\"\r" }
1' infile

I think MS EXCEL needs the ^M after each line but the last in a multiline cell. Try to make it

"Observation 1^MSource Rows not load^MScore drop"

I'm sorry I can't test it - this is a MS - free computer.