Sponsored Content
Top Forums Shell Programming and Scripting Script to convert csv file to html with good visibility Post 302710399 by rdrtx1 on Thursday 4th of October 2012 11:43:35 AM
Old 10-04-2012
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.csv


Last edited by rdrtx1; 10-04-2012 at 01:10 PM..
This User Gave Thanks to rdrtx1 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sample Unix script file to convert .xml to .csv

Dear all, Can you send me a script file the changes .xml to .csv file. Thanks, Srinivasa (4 Replies)
Discussion started by: srinivasaphani
4 Replies

2. UNIX for Dummies Questions & Answers

Unix script to convert .csv file to.xls format

I have a .csv file in Unix box i need a UNIX script to convert the.csv files to.xls format. Its very urgent please help me. (1 Reply)
Discussion started by: moon_friend
1 Replies

3. UNIX for Dummies Questions & Answers

convert csv to html file

Hi All, I am new to this forum,not sure where to post this query...so posted here Kindly need any of your help on the below ------------ I am using shell scripting and trying to convert a csv file to html file... example.csv --------------- Name Country Age Sex Andy India 25 ... (4 Replies)
Discussion started by: sumithra
4 Replies

4. Shell Programming and Scripting

Is there any script which convert binary file to CSV format

Dear guys; I have a binary file and I need to convert its data to csv format ...appreciating your help. Best Regards (14 Replies)
Discussion started by: ahmad.diab
14 Replies

5. Shell Programming and Scripting

Awk script to convert csv to html

Hi Written some script to convert csv to html but could not add table headers.Below are the errors iam getting ./csv2html | more + awk -v border=1 -v width=10 -v bgcolor=black -v fgcolor=white BEGIN { printf("<table border=\"%d\" bordercolor=\"%s\" width=\"%d\"... (2 Replies)
Discussion started by: zeebala1981
2 Replies

6. Shell Programming and Scripting

Convert shell script output txt file to html table

Hi, I have script which generates the output as below: Jobname Date Time Status abc 12/9/11 17:00 Completed xyz 13/9/11 21:00 Running I have the output as a text file. I need to convert it into a HTML Table and sent it thru email ... (6 Replies)
Discussion started by: a12ka4
6 Replies

7. Shell Programming and Scripting

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 (4 Replies)
Discussion started by: sv0081493
4 Replies

8. Shell Programming and Scripting

Need script to convert TXT file into CSV

Hi Team, i have some script which give output in TXT format , need script to convert TXT file into CSV. Output.TXT 413. U-UU-LVDT-NOD-6002 macro_outcome_dist-8.0.0(v1_0_2) KK:1.2.494 (1234:333:aaa:2333:3:2:333:a) 414. U-UU-LVDT-NOD-6004 ... (10 Replies)
Discussion started by: Ganesh Mankar
10 Replies

9. Shell Programming and Scripting

Convert shell script output txt file to html table

My concnern related to the post -Convert shell script output txt file to html table, in this how to print the heading as color. awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print "</tr>"} END{print "</table>"}' <filename> (8 Replies)
Discussion started by: sarajobmai
8 Replies

10. Shell Programming and Scripting

Convert csv data to html format

I am new to html and need to convert the attached csv file data to html format ; running into issues. please assist. #!/bin/ksh echo "<html>" ; echo "<head><style> table {border-collapse: collapse;} table, td, th {border: 1px solid black;} </style></head>" echo "<title> REPORT </title>" echo... (0 Replies)
Discussion started by: archana25
0 Replies
Ufunc(3)						User Contributed Perl Documentation						  Ufunc(3)

NAME
PDL::Ufunc - primitive ufunc operations for pdl DESCRIPTION
This module provides some primitive and useful functions defined using PDL::PP based on functionality of what are sometimes called ufuncs (for example NumPY and Mathematica talk about these). It collects all the functions generally used to "reduce" or "accumulate" along a dimension. These all do their job across the first dimension but by using the slicing functions you can do it on any dimension. The PDL::Reduce module provides an alternative interface to many of the functions in this module. SYNOPSIS
use PDL::Ufunc; FUNCTIONS
prodover Signature: (a(n); int+ [o]b()) Project via product to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the product along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = prodover($b); $spectrum = prodover $image->xchg(0,1) dprodover Signature: (a(n); double [o]b()) Project via product to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the product along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = dprodover($b); $spectrum = dprodover $image->xchg(0,1) Unlike prodover, the calculations are performed in double precision. cumuprodover Signature: (a(n); int+ [o]b(n)) Cumulative product This function calculates the cumulative product along the 1st dimension. By using xchg etc. it is possible to use any dimension. The sum is started so that the first element in the cumulative product is the first element of the parameter. $a = cumuprodover($b); $spectrum = cumuprodover $image->xchg(0,1) dcumuprodover Signature: (a(n); double [o]b(n)) Cumulative product This function calculates the cumulative product along the 1st dimension. By using xchg etc. it is possible to use any dimension. The sum is started so that the first element in the cumulative product is the first element of the parameter. $a = cumuprodover($b); $spectrum = cumuprodover $image->xchg(0,1) Unlike cumuprodover, the calculations are performed in double precision. sumover Signature: (a(n); int+ [o]b()) Project via sum to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the sum along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = sumover($b); $spectrum = sumover $image->xchg(0,1) dsumover Signature: (a(n); double [o]b()) Project via sum to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the sum along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = dsumover($b); $spectrum = dsumover $image->xchg(0,1) Unlike sumover, the calculations are performed in double precision. cumusumover Signature: (a(n); int+ [o]b(n)) Cumulative sum This function calculates the cumulative sum along the 1st dimension. By using xchg etc. it is possible to use any dimension. The sum is started so that the first element in the cumulative sum is the first element of the parameter. $a = cumusumover($b); $spectrum = cumusumover $image->xchg(0,1) dcumusumover Signature: (a(n); double [o]b(n)) Cumulative sum This function calculates the cumulative sum along the 1st dimension. By using xchg etc. it is possible to use any dimension. The sum is started so that the first element in the cumulative sum is the first element of the parameter. $a = cumusumover($b); $spectrum = cumusumover $image->xchg(0,1) Unlike cumusumover, the calculations are performed in double precision. orover Signature: (a(n); int+ [o]b()) Project via or to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the or along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = orover($b); $spectrum = orover $image->xchg(0,1) bandover Signature: (a(n); int+ [o]b()) Project via bitwise and to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the bitwise and along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = bandover($b); $spectrum = bandover $image->xchg(0,1) borover Signature: (a(n); int+ [o]b()) Project via bitwise or to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the bitwise or along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = borover($b); $spectrum = borover $image->xchg(0,1) zcover Signature: (a(n); int+ [o]b()) Project via == 0 to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the == 0 along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = zcover($b); $spectrum = zcover $image->xchg(0,1) andover Signature: (a(n); int+ [o]b()) Project via and to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the and along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = andover($b); $spectrum = andover $image->xchg(0,1) intover Signature: (a(n); int+ [o]b()) Project via integral to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the integral along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = intover($b); $spectrum = intover $image->xchg(0,1) Notes: For "n > 3", these are all "O(h^4)" (like Simpson's rule), but are integrals between the end points assuming the pdl gives values just at these centres: for such `functions', sumover is correct to O(h), but is the natural (and correct) choice for binned data, of course. average Signature: (a(n); int+ [o]b()) Project via average to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the average along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = average($b); $spectrum = average $image->xchg(0,1) daverage Signature: (a(n); double [o]b()) Project via average to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the average along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = daverage($b); $spectrum = daverage $image->xchg(0,1) Unlike average, the calculation is performed in double precision. medover Signature: (a(n); [o]b(); [t]tmp(n)) Project via median to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the median along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = medover($b); $spectrum = medover $image->xchg(0,1) oddmedover Signature: (a(n); [o]b(); [t]tmp(n)) Project via oddmedian to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the oddmedian along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = oddmedover($b); $spectrum = oddmedover $image->xchg(0,1) The median is sometimes not a good choice as if the array has an even number of elements it lies half-way between the two middle values - thus it does not always correspond to a data value. The lower-odd median is just the lower of these two values and so it ALWAYS sits on an actual data value which is useful in some circumstances. pctover Signature: (a(n); p(); [o]b(); [t]tmp(n)) Project via percentile to N-1 dimensions This function reduces the dimensionality of a piddle by one by finding the specified percentile (p) along the 1st dimension. The specified percentile must be between 0.0 and 1.0. When the specified percentile falls between data points, the result is interpolated. By using xchg etc. it is possible to use any dimension. $a = pctover($b, $p); $spectrum = pctover $image->xchg(0,1) $p oddpctover Signature: (a(n); p(); [o]b(); [t]tmp(n)) Project via percentile to N-1 dimensions This function reduces the dimensionality of a piddle by one by finding the specified percentile along the 1st dimension. The specified percentile must be between 0.0 and 1.0. When the specified percentile falls between two values, the nearest data value is the result. By using xchg etc. it is possible to use any dimension. $a = oddpctover($b, $p); $spectrum = oddpctover $image->xchg(0,1) $p pct Return the specified percentile of all elements in a piddle. The specified percentile (p) must be between 0.0 and 1.0. When the specified percentile falls between data points, the result is interpolated. $x = pct($data, $pct); oddpct Return the specified percentile of all elements in a piddle. The specified percentile must be between 0.0 and 1.0. When the specified per- centile falls between two values, the nearest data value is the result. $x = oddpct($data, $pct); avg Return the average of all elements in a piddle $x = avg($data); sum Return the sum of all elements in a piddle $x = sum($data); prod Return the product of all elements in a piddle $x = prod($data); davg Return the average (in double precision) of all elements in a piddle $x = davg($data); dsum Return the sum (in double precision) of all elements in a piddle $x = dsum($data); dprod Return the product (in double precision) of all elements in a piddle $x = dprod($data); zcheck Return the check for zero of all elements in a piddle $x = zcheck($data); and Return the logical and of all elements in a piddle $x = and($data); band Return the bitwise and of all elements in a piddle $x = band($data); or Return the logical or of all elements in a piddle $x = or($data); bor Return the bitwise or of all elements in a piddle $x = bor($data); min Return the minimum of all elements in a piddle $x = min($data); max Return the maximum of all elements in a piddle $x = max($data); median Return the median of all elements in a piddle $x = median($data); oddmedian Return the oddmedian of all elements in a piddle $x = oddmedian($data); any Return true if any element in piddle set Useful in conditional expressions: if (any $a>15) { print "some values are greater than 15 " } all Return true if all elements in piddle set Useful in conditional expressions: if (all $a>15) { print "all values are greater than 15 " } minmax Returns an array with minimum and maximum values of a piddle. ($mn, $mx) = minmax($pdl); This routine does not thread over the dimensions of $pdl; it returns the minimum and maximum values of the whole array. See minmaximum if this is not what is required. The two values are returned as Perl scalars similar to min/max. perldl> $x = pdl [1,-2,3,5,0] perldl> ($min, $max) = minmax($x); perldl> p "$min $max "; -2 5 qsort Signature: (a(n); [o]b(n)) Quicksort a vector into ascending order. print qsort random(10); qsorti Signature: (a(n); int [o]indx(n)) Quicksort a vector and return index of elements in ascending order. $ix = qsorti $a; print $a->index($ix); # Sorted list minimum Signature: (a(n); [o]c()) Project via minimum to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the minimum along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = minimum($b); $spectrum = minimum $image->xchg(0,1) minimum_ind Signature: (a(n); int [o] c()) Like minimum but returns the index rather than the value minimum_n_ind Signature: (a(n); int[o]c(m)) Returns the index of "m" minimum elements maximum Signature: (a(n); [o]c()) Project via maximum to N-1 dimensions This function reduces the dimensionality of a piddle by one by taking the maximum along the 1st dimension. By using xchg etc. it is possible to use any dimension. $a = maximum($b); $spectrum = maximum $image->xchg(0,1) maximum_ind Signature: (a(n); int [o] c()) Like maximum but returns the index rather than the value maximum_n_ind Signature: (a(n); int[o]c(m)) Returns the index of "m" maximum elements minmaximum Signature: (a(n); [o]cmin(); [o] cmax(); int [o]cmin_ind(); int [o]cmax_ind()) Find minimum and maximum and their indices for a given piddle; perldl> $a=pdl [[-2,3,4],[1,0,3]] perldl> ($min, $max, $min_ind, $max_ind)=minmaximum($a) perldl> p $min, $max, $min_ind, $max_ind [-2 0] [4 3] [0 1] [2 2] See also minmax, which clumps the piddle together. AUTHOR
Copyright (C) Tuomas J. Lukka 1997 (lukka@husc.harvard.edu). Contributions by Christian Soeller (c.soeller@auckland.ac.nz) and Karl Glaze- brook (kgb@aaoepp.aao.gov.au). All rights reserved. There is no warranty. You are allowed to redistribute this software / documentation under certain conditions. For details, see the file COPYING in the PDL distribution. If this file is separated from the PDL distribution, the copyright notice should be included in the file. perl v5.8.0 2003-01-29 Ufunc(3)
All times are GMT -4. The time now is 09:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy