Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Merge cells in all rows of a HTML table dynamically. Post 303011396 by Mounika on Thursday 18th of January 2018 12:51:53 AM
Old 01-18-2018
Thank you for your response!!

Considering the sample output below:
Code:
12345,XYZ,123,PPP,01,AAAAAAAAAA,DEFGDEFG
12345,XYZ,234,ABC,02,AAAAAAAAAA,DEFGDEFG
12345,XYZ,567,ABC,05,AAAAAAAAAA,HHHHHHH
45167,XYZ,809,ABC,09,BBBBBBBBBB,HHHHHHH
45167,XYZ,222,ABC,04,BBBBBBBBBB,DEFGDEFG

In the first column we have 12345 value present in first 3 rows. So for the first 3 rows, first column should be a merged value showing single merged value 12345 instead of 3. In other words equivalent to rowspan in HTML or Merge in Excel sheet.

considering last 2 rows, instead of it displaying 45167 value twice it should only display it once with 4th and 5th rows first column as a merged cell.

If you consider second column, all the values in that column for all rows is XYZ. So, instead of showing the same value XYZ 5 times, it should show XYZ as a single value with all 5 cells as a single merged cell.

Similarly for others.
Code:
12345	XYZ	123	PPP	1	AAAAAAAAAA	DEFGDEFG
12345	XYZ	234	ABC	2	AAAAAAAAAA	DEFGDEFG
12345	XYZ	567	ABC	5	AAAAAAAAAA	HHHHHHH
45167	XYZ	809	ABC	9	BBBBBBBBBB	HHHHHHH
45167	XYZ	222	ABC	4	BBBBBBBBBB	DEFGDEFG

Say this is the initial HTML format I got in mail

The same should be converted to below.

Code:
12345	XYZ	123	PPP	1	AAAAAAAAAA	DEFGDEFG
		234	ABC	2		
		567		5		HHHHHHH
45167		809		9	BBBBBBBBBB	
		222		4		DEFGDEFG

I hope this gives a clear picture.

Last edited by Mounika; 01-18-2018 at 01:56 AM.. Reason: Provided modified output which is needed.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting table cells in a script

I'd like to use sed or awk to do this but I'm weak on both along with RE. Looking for a way with sed or awk to count for the 7th table data within a table row and if the condition is met to delete "<td>and everything in between </td>". Since the table header start on a specific line each time, that... (15 Replies)
Discussion started by: phpfreak
15 Replies

2. Shell Programming and Scripting

How to merge rows into columns ????

Hi guz I want to merge multiple rows into a multiple columns based on the first column. The file has symbol // I want to break the symbool // and I nedd exactlynew column at that point the output will be like this please guyz help in this isssue!!!!! merging rows into columns ... (4 Replies)
Discussion started by: bogu0001
4 Replies

3. Programming

How do I change html style dynamically

I've got the following form element in a template driven web page... <INPUT type="text" class="normal" id="LastName" name="LastName" value="{LastName}"> The stylesheet description is simply... input.normal { width: 250; } I want to change the background colour of the input box after the user... (0 Replies)
Discussion started by: JerryHone
0 Replies

4. Shell Programming and Scripting

Merge two cells in excel via UNIX?

Hi UNIX Gods! Is it possible to merge two cells in .csv file using unix commands? Imagine that this is my present csv file opened via excel: Gate Reports| | fatal alerts | 200 | is is possible to make it look like this using unix? Gate Reports | fatal... (1 Reply)
Discussion started by: 4dirk1
1 Replies

5. Shell Programming and Scripting

extract complex data from html table rows

I have bash, awk, and sed available on my portable device. I need to extract 10 fields from each table row from a web page that looks like this: </tr> <tr> <td>28 Apr</td> <td><a... (6 Replies)
Discussion started by: rickgtx
6 Replies

6. Programming

Perl script to merge cells in column1 which has same strings, for all sheets in a excel workbook

Perl script to merge cells ---------- Post updated at 12:59 AM ---------- Previous update was at 12:54 AM ---------- I am using below code to read files from a dir and print to excel. open(my $in, '<', $file) or die "Could not open file: $!"; my $rowCount = 0; my $colCount = 0;... (11 Replies)
Discussion started by: Jack_Bruce
11 Replies

7. UNIX for Beginners Questions & Answers

Putting query result dynamically to one cell of table from shell

I have to send a data in mail table format.only one cell need to get dynamically from query. my code is like (echo '<table boarder="1"> echo '<tr><td>stock</td><td>/path</td><td>.........</td></tr>' echo '</table> )sendmail.. in ......... I am trying to get query result.By putting query... (2 Replies)
Discussion started by: meera_123
2 Replies

8. Shell Programming and Scripting

Parameterizing to dynamically generate the extract file from Oracle table using Shell Script

I have below 2 requirements for parameterize the generate the extract file from Oracle table using Shell Script. Could you please help me by modifying the script and show me how to execute it. First Requirement: I have a requirement where I need to parameterize to generate one... (0 Replies)
Discussion started by: hareshvikram
0 Replies

9. UNIX for Beginners Questions & Answers

Remove duplicates in a dataframe (table) keeping all the different cells of just one of the columns

Hello all, I need to filter a dataframe composed of several columns of data to remove the duplicates according to one of the columns. I did it with pandas. In the main time, I need that the last column that contains all different data ( not redundant) is conserved in the output like this: A ... (5 Replies)
Discussion started by: pedro88
5 Replies

10. UNIX for Beginners Questions & Answers

Merge Multiple html files into one

Hi all I have written some code to write my output in html. As i have multiple servers, need to generate single html file. but my code is generating html file for each server. I have merged the files using below code. cat /home/*_FinalData.html > /home/MergedFinalData.html But how to... (1 Reply)
Discussion started by: Snehasish
1 Replies
FREETABLE(1)							     Freetable							      FREETABLE(1)

NAME
freetable - tool for making HTML tables generation easier VERSION
This manpage describes version 2.3 of freetable. It might be not 100% accurate if you use different version. SYNOPSIS
freetable [options] filename or freetable [options] Possible options are : -h, --help Print usage info and exit -V, --version Print version information and exit -c, --comment Insert comment before every cell to point its location -b, --no-nbsp Do not insert &nbsp; to empty cells for lowered-3D apperance -w, --warning Print a warning before each generated table that you should not change it. You should change its source. -l, --location Substitute <row> and <col> flags inside table with correct cell's location -m, --macro [program] Use macro procesor to proces cells content (default: m4) WARNING
DO NOT USE MACRO PROCESSOR OVER UNSURE SOURCE M4 MAY BE USED TO COMPROMISE YOUR SECURITY FOR MORE INFORMATION ON THIS EXEC : info m4 'UNIX commands' syscmd DESCRIPTION
This is free replacement of wwwtable HTML is great language, but have one horrible flaw : tables. I spent many hours looking at HTML source I just written and trying to guess which cell in source is which in browser. If this also describes you, then read this manpage and your pain will stop. Program read HTML source from either stdin or file. Then it searches for line starting table: <wwwtable [options]> Then it analyzes table, put correct HTML table in this place and continue searching for the next table. TABLE SYNTAX
It is very easy: wwwtable : <wwwtable [wwwtable_options]> [preamble] [cell] [cell] ... </wwwtable> wwwtable_options will be passed to <table> tags. There is no magic inside preamble. It can be any HTML text. It will be simply put in front of table. cell is either normal_cell (<td> tag) or header_cell (<th> tag). At least it was this way in freetable 1.x. See the next section for alternative cell address syntax. normal_cell : (row,col) cell_options cell_content header_cell : ((row,col)) cell_options cell_content cell_options will be passed to cell tag. There is magic inside colspan and rowspan keys are parsed to make correct table. cell_content can be anything. It may contain text, tags, and even nested wwwtables. If you use -m (or --macro) option, it will be passed thru m4(1), with <row> and <col> set to adress of curent cell row and col are either numbers locating cells, expressions relative to previous cell or regular expresions to match few of them. Unlike wwwtable, freetable can use regular expresions for header cells. Also * can be used, and it mean .* really. Relative expressions are : = or empty means : the same as previous + or +X means : one and X more than previous - or -X means : one and X less than previous If many definisions adress the same cell all options and contents are concatenated in order of apperance. If you want to use only regular expresions you must tell program about the last cell : <wwwtable> (*,1) these are colums 1 (1,*) these are rows 1 (4,4) </wwwtable> ALTERNATIVE CELL ADDRESS SYNTAX
It is inconvenient to specify cell address as regular expression. So in freetable 2.0 two new methods were introduced. Both can be used to either normal or header cells. Full bakward compatibility is preserved. To preserve it, new syntax had to be introduced. Unfortunatelly, you can't specify row address using one method, and column address using another. To come around this, both new methods are very liberal and allow you to use =, +, -, +X -X and null string with the same meaning as they have in old addressing method. Unlike regular expression method, new methods will find out the last cell automatically. EXPLICIT RANGES (rowrange;colrange) cell_options cell_content Syntax for both rowrange and colrange is like: 1-2,4-7,9,12. Duplicates will be eliminated. For purpose of relative addresses last given number is used. So if you write (1-100,32;1) foo (+,) bar Cell (33,1) will contain `foobar' and all others only `foo'. ARBITRARY PERL CODE ({code for rows},{code for tables}) cell_options cell_content You can use arbitrary Perl one-liner as long as it matches our not very intelligent regular expressions and evaluates to list. Unfortu- natelly there isn't any regular expression for Perl code, but as long as it doesn't contain },{ and }) it should work. Example: <wwwtable> ({grep {$_%3 == 1} 1..100},{1..2,4}) foo </wwwtable> Will evaluate to 100 rows x 4 columns table with `foo' in every 1st, 2nd and 4th column of every row with number equal 1 modulo 3. If you want to use "arbitrary code" in one part of address and explicit range in the other, change - into .. in defenition of range, and put in between { and }. If you want to use "arbitrary code" in one part of address and regular expression in the other, you have to write {grep {/expression/} from..to}. Unfortunatelly, in this case you have to specify size of the table explicitely. INCOMPATIBILITIES WITH WWWTABLE
If you was formerly user of wwwtable and want to change your tool, you should read this. Most of this is about regexps handling. Notice also that wwwtable couldnt do location tags substitution nor macroprocesing. Option -w has completely oposite meaning. We dont print warnings by default, and -w or --warning is used to force warnings. Table header fields can be specified by regexps ex : ((1,*)) It was impossible in wwwtable. Axis counters are 100% orthogonal. This mean that code : (*,1) width=30 (*,2) width=35 (*,3) width=40 (=,=) Foo Foo will appear in 3rd column. If you wanted it to be in 1st you should write : (*,1) width=30 (*,2) width=35 (*,3) width=40 (=,1) Foo or (*,) width=30 (*,+) width=35 (*,+) width=40 (=,1) Foo In freetable 2.0 two new methods o specifying cell address were introduced. They are completely incompatible with wwwtable. BUGS
"Arbitrary Perl Code" cell address will fail on very complex Perl code. SEE ALSO
m4(1) AUTHOR
Tomasz Wegrzanowski <taw@users.sourceforge.net> perl v5.8.8 2001-12-02 FREETABLE(1)
All times are GMT -4. The time now is 07:57 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy