Convert a List of items into 2 Columns

Dears,

I have one text file having some items each one equals to certain value.
How to Convert a List of items into 2 Columns?
Example :

alpha=3
beta=6
theta=8
zeta=9
kapa=4

Thanks

Hi,

There are some ways to achieve it. If there is no special character in your list, the following is one of the easiest ways.

Or, the following expression will work.

Make datatable which has 2 columns in advance.
Then,

dt = listVar.Select(Function(s) dt.Clone.LoadDataRow({s.Split("="c)(0),s.Split("="c)(1)},False)).CopyToDataTable()

Regards,

1 Like

Thanks a lot @Yoichi , it’s working fine, last thing, How to add column headers for Generated Datatable, instead of having “Column 1 & Column 2”? Thx

Hi,

Use the following expression to rename column using Assign activity.

dt.Columns(0).ColumnName = "NewName1"
dt.Columns(1).ColumnName = "NewName2"

OR

Insert item to the List at first position before use GenerateDataTable and check UseColumnHeader option.

"NewName1=NewName2"

Regards,

1 Like

Excellent Tricks, It’s Working fine . Thanks a lot @Yoichi for your support :+1:

1 Like

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