Split String in Excel file

Hi,
I need to split the strings in an excel file with “:” as my reference and anything that is left of the colon should be my column name and the corresponding value on the right side of the colon should be placed below that column name. Cells which are empty/ doesn’t have a colon must be deleted. I don’t know how to do this. Can anyone help me with this?

Thanks in advance :slight_smile:

PF the excel file attached.Book1.xlsx (8.3 KB)

Need one confirmation -

In this case,
you lose the countries list right. In the below image, as per your requirement countries list contains only one value Thailand and will miss the other two. Is it expected?

image

Yeah is it possible to add Malaysia and Singapore along with thailand under countries list column in a single cell seperated by commas??

Regards,
Lokesh R

But the problem is how to identify these values. Because it is not separated by “:”. As per the requirement it has to be deleted.

May be you must change the way how the countries list is defined in this excel.

Regards,
Karthik Byggari

Okay. Can we able to format the other cells??

Regards,
Lokesh R

Yes.

That’s good. Can you solve this one?

Will send you the xaml after a while.

1 Like

Please find the attached xaml and sample output file.Book1.xlsx (9.7 KB)
Main.xaml (14.2 KB)

1 Like

image

This activity isn’t displaying on my UiPath Studio. Im using 2016.2 version. Any alternatives for this??

The missing activity here is “For Each” Loop Activity.
I developed the bot with the latest UIPath version.

There are just couple of assign activities in the for loop.
Do you want me to write those assign activities here. So you can build the missing activity.

Yeah. Go ahead.

FOR EACH [row] in [ExtractData]

--------BODY OF FOR LOOP-----------------

      IF row(0).ToString.Contains(":")

          ---------If condition is TRUE---------

                ASSIGN: iIndex = row(0).ToString.IndexOf(":")
                ASSIGN: colName = row(0).ToString.Substring(0, iIndex-1).Trim
                ASSIGN: tempValue = tempValue + "," + row(0).ToString.Substring(iIndex+1,row(0).ToString.Length - iIndex -1).Trim

                ADD DATA COLUMN ACTIVITY: 
                  In the PROPERTIES -
                    ColumnName: colName
                    DataTable: outDT
                    AllowDBNull: True

          ---------End of IF Activity-----------

---------END OF FOR EACH Activity--------
2 Likes

image

image

Hi Man, Im getting an exception for this assign activity, what’s wrong with it?

tempvalue is not assigned before assigning. So you are getting this error.
Add a if condition for this assign activity. If tempvalue is null, do not assign anything.