Script to convert CSV file to HTML

Hi,

I have made a a script which creates a csv file as daily database report
However i want to covert that csv file to html because csv file does not have a good visibilty.
So it is possible to have such csv to html coversion script.

Your prompt help much appreciated. Thanks in advance

From where you are generating the csv file?

1 Like
[root@host dir]# cat file.csv
col1,col2,col3,col4
a,b,c,d
e,f,g,h
[root@host dir]#
[root@host dir]# perl -F',' -lane 'BEGIN{open O, ">output.html"; print O "<html><body><table border=1>"}; chomp;
print O "<tr>";
print O "<th>$_<\/th>" for (@F);
print O "<\/tr>";
END {print O "<\/table><\/body><\/html>"; close O}' file.csv
[root@host dir]#
[root@host dir]# cat output.html
<html><body><table border=1>
<tr>
<th>col1</th>
<th>col2</th>
<th>col3</th>
<th>col4</th>
</tr>
<tr>
<th>a</th>
<th>b</th>
<th>c</th>
<th>d</th>
</tr>
<tr>
<th>e</th>
<th>f</th>
<th>g</th>
<th>h</th>
</tr>
</table></body></html>
1 Like

Simple you can try...

select dbms_xmlquery.getxml('select * from emp') from dual; 
1 Like

Hi,

Thanks for prompt response.
I am calling sql query in a shell script and writing output of that query to csv.
Then i need further script to convert this csv file to html and want to have an automted mail from server containing the html file which is created with a good visibilty.