Solved Change Header names in collection

Hi All,

I have scenario like this

I have 10 pages to read a web table.
I read data from web page into collection (say A) and every time this collection I am appending to another collection(say B) (to save the all 10 pages data into one collection). I wanted to change B collection headers. For this , i did like this : each column I created data item and assigned to each column using multi calc --- upto here code worked fine.

After new header collection created I used collection manipulation and action name :rename collection field action to change the header name. But I am getting below error.

Attached error ,calc, header collection and input collection.
 

Attachments

  • 1.calc stage.PNG
    86.6 KB · Views: 278
  • header collection1.PNG
    60.1 KB · Views: 232
  • header collection1_after execution of calc stage.PNG
    30.7 KB · Views: 301
  • error.PNG
    27.1 KB · Views: 158
  • incoming collection.PNG
    82 KB · Views: 157
  • rename header stage.PNG
    59.5 KB · Views: 162

sivagelli

Well-Known Member
Looking at the error, BP is looking for Field PON in the collection and is failing to find it.

Looking at the steps you followed, i do not see anything wrong, however there is error looking for PON field. Make sure you are using the collections/collection names correctly.

May be instead of using a Data Items and Multi Calc stage you can give a try by creating Header Collection and have the fields names same as the fields from collection B. Now, add a row to Header Collection and add new field names as values to the corresponding fields. Then use the Action Rename Collection Fields.

On using the Rename Collection Fields Name action, output collection will have renamed fields.

Post back, how it goes!
 
Last edited:
I tried What you said. That rename action field . Still getting same error. This time I given new name as "rename" popping same error with new name " rename "
 

Attachments

  • 1.calc stage.PNG
    34 KB · Views: 154
  • 2.PNG
    48.5 KB · Views: 131
  • 3.PNG
    49.2 KB · Views: 100
Hi All,

I have scenario like this

I have 10 pages to read a web table.
I read data from web page into collection (say A) and every time this collection I am appending to another collection(say B) (to save the all 10 pages data into one collection). I wanted to change B collection headers. For this , i did like this : each column I created data item and assigned to each column using multi calc --- upto here code worked fine.

After new header collection created I used collection manipulation and action name :rename collection field action to change the header name. But I am getting below error.

Attached error ,calc, header collection and input collection.
Yes, Before I used that only, and I got the error. Check "rename header stage Screenshot"
 

sivagelli

Well-Known Member
It worked perfectly well for me, I modified the headers of collection with no issues using the action "Rename Collection Fields".
 
Yeah, I did it for another collection it worked. For example I m reading my table data from web page and storing it into a collection called A. And I wanted to rename my collection A header. Than if i use Rename collection fields Action . It will work.
But here I am taking my web table values into collection A and appending into collection B. From this step means I want to change header name of B collection . Its not working as expected.
 

sivagelli

Well-Known Member
But here I am taking my web table values into collection A and appending into collection B
When you say this, what is the action you are performing?

I tried replicating your case, i have 2 collections
  • Coll1 with Field1, Filed2
  • Coll2 with Field3, Field4

I merged these two collections, using Merge Collection action. The output collection is a now having fields Field1, Filed2, Field3 & Field4. Lets calls this MergedColl

Now, i created a collection newFieldNameColl with fields same as MergedColl. Added a row to this collection and add values Column1, Column2, Column3 &Column4.

Used "Rename Collection Fields" action passing arguments as MergedColl, newFieldNameColl. This has resulted in a collection which has field names Column1, Column2, Column3 & Column4 with no errors.
 
No No. I am appending the rows. The two collections which I m mentioning A and B has same no. of columns. But After Appending the rows into B collection i m doing some steps like removing empty rows and removing empty cols. so after filtering the proper data which I need , I m doing header change. Means My header names of B collection is like this Column2, column3, Column4 ................ Column14.
Ok?
For those header names I wanted to change as PON, SUP,ASR, ........................ Action.
 

sivagelli

Well-Known Member
Means My header names of B collection is like this Column2, column3, Column4 ................ Column14.
Ok?
For those header names I wanted to change as PON, SUP,ASR, ........................ Action.

Create a collection with fields Column2....Column14 and have a single row with values PON, SUP, ASR...respectively

On using the Rename Collection Fields, it should work ideally.
 

VJR

Well-Known Member
Hi Divyarani411,

You may have already sorted this out after all of your conversation above. If not please try the suggestions given by sivagelli.

After your collection looks like the below (header-collection1_after-execution-of-calc-stage-png), if you use 'Set Column Names From First Row' action, it will turn the column headers into the data that is present in its first row.
header-collection1_after-execution-of-calc-stage-png.2670
 
Hi VJR,

After setting the first Row as above shown pic. I used Set Column Names From First Row' action . I am not facing any errors but My result collection goes Empty. Out put I gave the collection records which I wanted to change my col names.
Input collection I gave the header names collection as there in above pic ((header-collection1_after-execution-of-calc-stage-png ).
 

Attachments

  • 22.PNG
    40 KB · Views: 136
  • 11.PNG
    43.5 KB · Views: 117

sivagelli

Well-Known Member
Alright! Lets think of other ways to deal this, write the collection in to an Excel worksheet and change the first row values and read the range in to a collection.
 

VJR

Well-Known Member
Hi VJR,

After setting the first Row as above shown pic. I used Set Column Names From First Row' action . I am not facing any errors but My result collection goes Empty. Out put I gave the collection records which I wanted to change my col names.
Input collection I gave the header names collection as there in above pic ((header-collection1_after-execution-of-calc-stage-png ).
In that case I did not fully understand your requirements.
While you still carry on your conversation on this thread, if you are able to then do share with screenshots of
i. how your collection data and its headers are looking right now?
ii. how do you want the collection data and its headers to look like?
If you are unable to create the collection for the sake of screenshots then you can show it in an Excel too.
 
In that case I did not fully understand your requirements.
While you still carry on your conversation on this thread, if you are able to then do share with screenshots of
i. how your collection data and its headers are looking right now?
ii. how do you want the collection data and its headers to look like?
If you are unable to create the collection for the sake of screenshots then you can show it in an Excel too.
Thank you!
Attaching the screenshots.
1) Current collection data is - collection data screenshot
2) Desire output collection data is - output collection
 

Attachments

  • OUTPUT Collection.PNG
    86.7 KB · Views: 131
  • collection data.PNG
    62.2 KB · Views: 121

VJR

Well-Known Member
Hi Divyarani411,

After using 'Set Column Names From First Row' action, if you are using 'Get Wksht as collection' then in that case the collection column names and the excel headers should exactly match. For example, DateSent and DSENT are different and hence cannot transfer the data.

Also to be noted that when you use 'Rename Field', in the Outputs tab you need to give a new collection name. It does not work if you give the same collection name.

Similarly if you use 'Rename Collection Fields' then if your original collection looks like this
View attachment 1543984531330.png

then you need to map those columns from your original collection as below with the new column headers in the first row
View attachment 1543984562889.png

And then use the action as per below
View attachment 1543984643449.png
In the Outputs tab you need to give a new collection name.

After you use the Rename Collecton Fields action your Input and Output would look like the below.
Before:
View attachment 1543984742444.png

After:
You can see the new column headers here.
View attachment 1543984768981.png

You can choose whichever option you prefer based on the above explanations for both of them - either Rename Collection Fields or Rename Field.

As a side note, if you want to dynamically add a blank row you can do so by using the Add Row action of the Collections VBO (not Utility Collections).
 
Hi Divyarani411,

After using 'Set Column Names From First Row' action, if you are using 'Get Wksht as collection' then in that case the collection column names and the excel headers should exactly match. For example, DateSent and DSENT are different and hence cannot transfer the data.

Also to be noted that when you use 'Rename Field', in the Outputs tab you need to give a new collection name. It does not work if you give the same collection name.

Similarly if you use 'Rename Collection Fields' then if your original collection looks like this
View attachment 2691

then you need to map those columns from your original collection as below with the new column headers in the first row
View attachment 2692

And then use the action as per below
View attachment 2693
In the Outputs tab you need to give a new collection name.

After you use the Rename Collecton Fields action your Input and Output would look like the below.
Before:
View attachment 2694

After:
You can see the new column headers here.
View attachment 2695

You can choose whichever option you prefer based on the above explanations for both of them - either Rename Collection Fields or Rename Field.

As a side note, if you want to dynamically add a blank row you can do so by using the Add Row action of the Collections VBO (not Utility Collections).
Thank you Its working fine. Basic mistake I did is given output collection same as input collection to append the data. If the choosen output collection than differently, it worked. Thank you so much VJR and sivagelli for your efforts and help. Thank you!

But One thing I would like to mention that if i used same collection as input and output to amend It worked for other case. So thats why I used here.
 
Last edited:
  • Like
Reactions: VJR
Top