cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert entire DataTable column into a string?

IrinaMihalache
Level 2
Hello,

I have an Excel file with 2000+ rows and it containing a column "Email Address". I have to concatenate all rows on that column, put a ";" between them and then paste that huge string into a "TO" field and send an email.

I tried looping throw all rows one by one and create that huge string but it takes too much time. Is there any solution for this, without using the Loop?
(TEXTJOIN and CONCAT functions from Excel apparently limit the numbers of values/characters you can merge, so for my 2000+ rows excel column it's not working)


Email Address
----------------
email 1
email 2
email 3
email 4
.
.
.
email 2000

Wanted result: "email 1; email 2; email 3; email 4;.........;email 2000"
10 REPLIES 10

ewilson
Staff
Staff
Hi @IrinaMihalache,

One option would be to get the column of email addresses as a Collection and then use the Join Text action of the Utility - Strings VBO to concatenate them all together. You may have to throw in a call to the Utility - Collection Manipulation's Rename Field action though. The reason for that is the Join Text action expects the input Collection to contain a field named Input Value.

I've attached a very rudimentary example process. This example assumes you're getting the collection of emails from an spreadsheet titled Emails.xlsx in the C:\temp folder. It also expecting a column header of Email. You can, of course, change all those.

Cheers,
Eric


Hi @ewilson 
Your reply is really helpful, thank you! I cannot see the example process you mention, could you repost it please? 

Thanks! 

David 

@whitehouse-UoL 

Unfortunately, there doesn't seem to be an option here for me to attach a file. I may not have permission, or it just may be a missing feature on this new community. Send me a DM and we'll see if I can get it to you that way. 

Cheers,

Eric

whitehouse-UoL
Level 4

Hi @ewilson 
Thank you for your email. I am very new to BP and I have run into an error that I am unsure how to resolve. 
The Error is: Internal : "Failed to translate data - No conversion available from Text to Collection"

It occurs At the very start of the "Utility - Strings::Join Text" Stage? 

Any suggests would be greatly appreciated. 

Thanks 
David

eab9a66a-d0f6-4315-a8ac-54a8aceecbd8.jpg




 

I should maybe also say I am working with ID numbers all numbers no text. 

Denis__Dennehy
Level 15

In terms of the speed of your original solution being too slow,  have you tried stepping out of the object with your logic or stepping over it in studio?   The reality is that a very large loop in studio can seem extremely slow because Blue Prism needs to draw the diagram changing - however usually the logic is extreamly rapid at runtime because it does not have to draw your diagram and becomes just a normal .NET coded for... next loop.

For the error you have got in a later comment we would need to see your calculation syntax to understand the cause of the error - which suggests you are not referencing your collection correctly.

Hi @Denis__Dennehy 
In the "Utility - Strings::Join Text" Stage I am referencing the collection like this, as I want only the rows of this feild to be created as a string. 

[Collection Out.Item Value]. 

whitehouseUoL_0-1717759469427.png

Does this look correct? 

Thanks
David 

 

@whitehouse-UoL what version of Blue Prism are you running, and do you have the latest release of the Utility - Strings VBO from the DX installed?

Hi @whitehouse-UoL ,

 

The problem is with the parameter that you are passing in the above screenshot. You need to pass a collection but you are passing a field column of the collection which seems to be of Text type.

 

Let me show you with an example on how you can achieve to get all the email addresses using the Join Text action.

Assuming I have a collection with me where let say I have multiple columns and one of the column consists of all the email addresses that I want to join as shown below:

devneetmohanty07_1-1717998439219.png

Now, what I want is to get all these email addresses as part of a single string. For this, I have created the below workflow:

devneetmohanty07_2-1717998549016.png

So first, I will call the Split Collection action from Collection Manipulation business object. This I would need so that I can just have a single collection with the email address column as the Join Text action expects us to pass the collection in the same way. For using the Split Collection action, you need to have two single row collections which will have the mentioned fields divided from your initial collection which you want to split.

For this I will have two collections, first one called Email Collection Template with the field name as 'Email Addresses' same as what I have in my initial collection and second collection is called Email Collection Template 2 with the other field values that we do not want from the initial collection. Please ensure the collection have single row option enabled as shown below:

devneetmohanty07_4-1717998920464.png

devneetmohanty07_5-1717999009945.png

Now, we will pass these collection templates and the initial collection called 'Data' where my original data is stored to the Split Collection action as shown below. In the output tab of this action, we will just assign Collection 2 parameter to another empty collection called Email Addresses as we just want the values for the 'Email Addresses' field as indicated in the first collection template:

devneetmohanty07_6-1717999168222.png

Once, we execute this action we will get the email addresses mentioned in just one column as part of the Email Addresses collection:

devneetmohanty07_8-1717999423279.png

 

Now, we will use rename the field of the collection from 'Email Addresses' to 'Item Value' because the Join Text action expects us to have a collection with just one column called as 'Item Value'. For this, we will use the Rename Field action from Collection Manipulation business object and rename the column in the Email Addresses collection and store the changes in the same collection as shown below:

devneetmohanty07_10-1717999569114.png

Once, we execute this action, you should have the updated Email Addresses collection with the column name now as 'Item Value':

devneetmohanty07_11-1717999674993.png

 

Now, we will finally use the 'Join Text' action from Strings business object and pass the Email Addresses collection along with ';' as the separator and we can enable the Trim Values parameter to get rid of extra spaces and this result will be stored in a text type data item:

devneetmohanty07_12-1717999849323.png

The result of this action should return you the data item with all the email addresses joined together as a string value:

devneetmohanty07_13-1717999916587.png

This way we can directly get the email addresses in a string without using any loops over a collection as mentioned before by @ewilson

 



 



---------------------------------------------------------------------------------------------------------------------------------------
Hope this helps you out and if so, please mark the current thread as the 'Answer', so others can refer to the same for reference in future.
Regards,
Devneet Mohanty,
SS&C Blueprism Community MVP 2024,
Automation Architect,
Wonderbotz India Pvt. Ltd.