Add data from column 3 to column 1

Hi guys,
I have a problem where I have to append data from different column. Here, I share the image.

I have to write Station from code in division from after “KGP” and “M/S. TISCO’S ROPEWAY SIDING” after Kharagpur. Output will look like this-

Can you help me with this ?
Nirmalya Sarkar

Am not able to see the screenshot Could you share the screenshoot

Hi @nirmalya.sarkar

You need for each row activity after reading the excel file:
Set in it an Assign activity and write:
row(“ColumnName1”) = row(“ColumnName2”).ToString + “/” + row(“ColumnName3”).ToString
ColumnName1 → is your destination column
ColumnName2 → is your first column which comes before the division
ColumnName3 → is your second column which comes after the division

After that you need to write the DataTable in Excel again.

Best regards

@copy_writes , Here it is.

@Dawodm , So I have to use a build data table to create a destination column. Right??

Hi @nirmalya.sarkar , how you are going to compare the data? Randomly adding third column from Station Code?

If you give some sample excel and your desired output then it would be helpful to give the solution.

@manjula_rajendran , my input is-

I have to show this in output-


How will I do it?

Nirmalya Sarkar.

Hi @nirmalya.sarkar ,

You can split the columns into 2 different table and for the first table write the second table data by add data row activity.
Example workflow is attached for you. Here in example i’ve table column name by index in case if you don’t have the column names.

MergeColumns.xaml (10.2 KB)
Division.xlsx (7.8 KB)

@manjula_rajendran , Thank you for solving it. But I don’t understand the code which you have written . Can you explain me the code or give the resources (Youtube videos) where I will understand these terms??

dt1 = dtTable.DefaultView.ToTable(False,“Division From”, “Location” )
dt2 = dtTable.DefaultView.ToTable(False,dtTable.Columns(2).ToString, dtTable.Columns(3).ToString)
dt2 = dt2.AsEnumerable.Skip(1).CopyToDataTable

Please help me to understand these terms.
Nirmalya Sarkar.

dt1 = dtTable.DefaultView.ToTable(False,“Division From”, “Location” )
dtTable is having the data of input excel. In the above expression i’m taking first 2 columns into dt1 table.

dt2 = dtTable.DefaultView.ToTable(False,dtTable.Columns(2).ToString, dtTable.Columns(3).ToString)
Same as above i’m taking 3rd and 4th column into dt2 table. As i don’t know the columns name I’m taking it with column index. If you have the unique column name then you can specify the column names.

dt2 = dt2.AsEnumerable.Skip(1).CopyToDataTable
I’m just removing the column headers here. As we don’t want to add with the column headers.

Filter Data Table is used to remove the empty rows.

Hope it is clear now.

1 Like

@manjula_rajendran , Just one last question -

What is significance of “False” (You have written under assign activity).

True or False in dtTable.DefaultView.ToTable() used to get the distinct or all values. If you used True it will get only distinct(unique) values.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.