|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
||||||||
|
||||||||
|
Script to convert csv file to html with good visibility
Hi, I have Below script which converts csv file to html succesfully.but the visiblity is simple in black n white. I want to have better visibilty of each columns in different colours(like green).As it is a Database report suppose some tablespace available space is less than 20% then it should come up in red colour.If the available space is above 20% then it should come up in green. Code:
perl -F',' -lane 'BEGIN{open O, ">output_db.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}' DBA_CHECKS.csvYour prompt help is much appreciated.
Last edited by Scott; 10-04-2012 at 08:17 AM.. Reason: Code tags |
| Sponsored Links | ||
|
|
#2
|
|||
|
|||
|
Code:
perl -F',' -lane 'BEGIN{
@bgc=("lightgreen","lightsteelblue");
open O, ">output_db.html"; print O "<html><body><table border=1><tbody>"
};
chomp;
print O "<tr>";
for $i (0..@F-1) {
print O "<td bgcolor=" . @bgc[$i % 2] . " >@F[$i]<\/td>"
}
print O "<\/tr>";
END {print O "</tbody><\/table><\/body><\/html>"; close O}' DBA_CHECKS.csv |
| The Following User Says Thank You to rdrtx1 For This Useful Post: | ||
sv0081493 (10-04-2012) | ||
| Sponsored Links | ||
|
|
#3
|
|||
|
|||
|
Hi rdrtx1,
Thanks a lot Script works great.. I had one query if you can help me.I have one column in that html report named "%Free" where it is showing how much % space is free.I want to add to that script suppose some tablespace %Free space is less than 20% then it should come up in red colour.If the %Free space is above 20% then it should come up in green. Could you please help here. |
|
#4
|
|||
|
|||
|
if the % column is # 2 (otherwise change $pct_col): Code:
#!/bin/ksh
perl -F',' -lane 'BEGIN{
$pct_col=2;
@bgc=("lightgreen","lightsteelblue");
open O, ">output_db.html"; print O "<html><body><table border=1><tbody>"
};
chomp;
print O "<tr>";
for $i (0..@F-1) {
$cbgc=@bgc[$i % 2];
if (${i} == ($pct_col - 1)) {
$pct=@F[$i];
$pct=~s/ *[%].*$//;
$pct=~s/^ *//;
$cbgc="red" if ($pct <= 20);
}
print O "<td bgcolor=" . $cbgc . " >@F[$i]<\/td>"
}
print O "<\/tr>";
END {print O "</tbody><\/table><\/body><\/html>"; close O}' DBA_CHECKS.csvLast edited by rdrtx1; 10-04-2012 at 12:10 PM.. |
| The Following User Says Thank You to rdrtx1 For This Useful Post: | ||
sv0081493 (10-04-2012) | ||
| Sponsored Links | |
|
|
#5
|
|||
|
|||
|
Hi,
Hats off mate it worked like wonder.Now I want to understand how the script is working.Could you please briefly explain how the script goes. |
| Sponsored Links | |
|
|
#6
|
||||
|
||||
|
@sv0081493: Don't you think you should mention in Post #1, from where you got that perl code !
|
| The Following User Says Thank You to balajesuri For This Useful Post: | ||
sv0081493 (10-05-2012) | ||
| Sponsored Links | |
|
|
#7
|
|||
|
|||
|
Hi Balajesuri,
Sorry if anything goes wrong from my side I am new to this forum.. Yes I accept i should mention that but forgot to mention.I will take care of these things in future posting Thanks a lot for your help. |
| The Following User Says Thank You to sv0081493 For This Useful Post: | ||
balajesuri (10-05-2012) | ||
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Script to convert CSV file to HTML | sv0081493 | Shell Programming and Scripting | 4 | 10-03-2012 08:37 AM |
| Need to convert datafeed to html using script | ranjancom2000 | Shell Programming and Scripting | 3 | 06-25-2012 01:55 PM |
| Convert shell script output txt file to html table | a12ka4 | Shell Programming and Scripting | 6 | 09-20-2011 04:12 AM |
| Awk script to convert csv to html | zeebala1981 | Shell Programming and Scripting | 2 | 03-04-2010 01:25 PM |
| visibility of a variable in Perl script. | Niroj | Shell Programming and Scripting | 1 | 12-18-2008 10:15 AM |
|
|