Skip to main content

Hello everyone,

 

I have a dataset with a lot of columns which do not contain data in every row. It is structured something like this:

 

imageWhat Im trying to do is create HTML-Reports for each Row but excluding the empty columns in each individual report, basically creating something like this:

 

Table in HTML Report 1

imageTable in HTML Report 2

imageTable in HTML Report 3

image 

Group Processing gets me halfway there but sadly keeps unnecessary columns. Is there a way to do this in FME? Any help appreciated.

What about processing it and then put a StringReplacer at the end replacing every emtpy <td></td> with nothing?


What about processing it and then put a StringReplacer at the end replacing every emtpy <td></td> with nothing?

I thought about that too. This unfortunately doesnt delete the column though, as the respective table header (for example <th>Column A</th>) would remain.


You could create the table with an XMLTemplater which will allow you to only create columns for attributes that have values. I might have an example somewhere i can dig out.


So something like this in an XML Templater, where _list{} is an ordered list of the columns you want to appear in the table

declare variable $attrs := {
  for $a in fme:get-list-attribute("_list{}")
  where (fme:has-attribute($a) and
   not (fn:string(fme:get-attribute($a)) eq "") )
  return $a};
<table class="table table-bordered">
  <thead>
  {
  for $colname in $attrs
  return
  <th>{$colname}</th>
 
}
</thead>
  <tbody>
  <tr>
  {
for $colname in $attrs
  return
  <td>{fme:get-attribute($colname)}</td>
 
}
</tr>
  </tbody>
</table>

 


Reply