Skip to main content

Hi,

I am trying to automate creation of template file from different forms into Excel spread sheet. There are many forms to extract information from. I am trying to first create a template of the column headers for each form into separate excel spread sheet.​

I managed to get all the column headers as a feature within each form_id as seen below.

imageAs you can see there can be many forms (form_id is unique for each form) and within each form_id i have column headers (label). how can I transpose these labels as column headers in excel (1 excel template for each form) and write them out in excel?

I have seen e.g. transposing columns into headers, but I'm not sure what I can do when I have dynamic number of forms and each form can have dynamic number of columns.

 

Any help is much appreciated!

Hello @lsugumar​ ,

The process for transposing columns into headers is mostly the same--you only need to ensure the correct group-by attribute is set in the Aggregator. In your case, it would be form_id.

Since your output format is Excel, one option is to take advantage of the Use Column Names as Attributes parameter in the Excel writer, so all forms use the same attribute names. With this option, you need to map your label to an Excel column name (eg, A-Z) using a transformer like the CharacterCodeReplacer.

In the Excel writer feature type, set Use Column Names as Attributes to 'Yes' and Output Field Names to 'No' and enable Dataset Fanout in the Excel writer based on form_id.

I have attached an example of this workflow. Note that the CharacterCodeReplacer works only if the number of labels is less than 27 in a form. You will need to find a way to map the 27th label to AA, 28th to AB, etc.


Hi @debbiatsafe,

Thank you for your response. Just curious to know, in your AttributeExposer, did you import data as "from feature cache"? If that's the case, when I do not know how many forms will come in (its dynamic number of forms), how can I use this in import process?


Hi @debbiatsafe,

Thank you for your response. Just curious to know, in your AttributeExposer, did you import data as "from feature cache"? If that's the case, when I do not know how many forms will come in (its dynamic number of forms), how can I use this in import process?

Hello @lsugumar​ 

Since my sample dataset was small, I did use the Import from Feature Cache option. Note that it is also possible to import from a dataset or manually input the attribute names (A-Z).

 

The same Excel output is also possible using a dynamic schema workflow along with the SchemaScanner. If you are unfamiliar with dynamic workflows, I would recommend reviewing these articles on dynamic schemas and using the SchemaScanner. With this workflow, you would want to ensure the correct regular expression is set in the Ignore Attributes Containing parameter for your input data. Attached is an example workspace.


Reply