Renaming headers in Collection
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
23-09-16 07:19 PM
Hello,
I'm trying to rename the headers on a collection. My goal is to do perform some calculations on the various rows, but since the headers on main collection are dynamic, I need to simplify the header naming in order to perform the calculations.
Inputs: Main Collection, New Headers
Output: Renamed Collection
Let's say I have "Main Collection" with the following structure:
Column1 | Column2
------------------------
Jason | 34
Instead of using the names Column1 and Column2, I would like to rename the headers to Name and Age. With the Collection Manipulation VBO, I can easily do that by using "Rename Headers" action. This requires me to create a new collection with the same headers, and a row with the new the name of new headers under their corresponding fields.
Example of "New Headers" collection:
Column1 | Column2
------------------------
Name | Age
Example of expected output (Renamed Collection):
Name | Age
---------------
Jason | 34
However, this is where my challenge occurs: My columns headers will be dynamic, because they will contain a date. This date will change every day. Basically, I won't know what my headers will be named the next day. So creating the "New header" collection is a big challenge. Also, after performing the calculations, I'd like to revert the column headers.
I found the action "Get Collection Fields", which retrieves the headers from "Main Collection" to a new collection, like "Collection Fields". I was thinking about looping through that collection, and add the rows as a field using the action "Append Field (Text)". This does not work however, because the collection I want to append to cannot be empty.
I think it would be easy to rename headers programming wise, but I'm not familiar with the code block, and how to use it.
Do you have any ideas on how I can solve this problem by using BP actions/stages?
3 REPLIES 3
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-09-16 05:41 PM
If the only problem is that the append-to collection cannot be empty, then just create an initial field and remove it after the loop ends so that you are left with the actual field headers only.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
27-09-16 06:36 PM
I ended up editing the initial code in ""Collection Manipulation VBO - Rename Headers"" in to a new BO. I can post the code here once I have tweaked it a bit more (exception management)!
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
30-09-16 12:28 PM
It would be much more easier to write your own action with the code stage inside adding new column to collection where you will give new column the name you want. Is you need help on writing any code stages I can help 😉
