Add data to a datatable

My input is
kali .d - ffsff
jai .v - fklfk
hari .v - fjdjj

This is User id and name i want to put this is a table
username (column 1)
kali .d
jai .v
hari .v

userid(column 2)
ffsff
fklfk
fjdjj
My inputs are in string

1 Like

@Karthikeyan34 how you’re giving this input,or you’re getting this input from any other source.

Fine
–we can use GENERATE DATATABLE activity and pass the above string input as input and mention the column separator as - in the property panel
–the output will be a datatable variable named outdt

or

if that doesnt seems working
–use a build datatable activity and create a datatable with two string type of columns and get the output with a variable of type dattable named outdt
–use a assign activity like this
hope you have that string input with a variable in_text
then
out_textarray = in_text.Split(Environment.Newline.ToArray())
where out_textarray is a string array variable
–now use a for each loop and pass the above variable out_textarray as input and change the type argument as string in the property panel
–inside the loop use a assign activity and mention like this
row(“yourcolumn1name”) = Split(item,"-")(0).ToString.Trim
another assign activity like this
row(“yourcolumn2name”) = Split(item,"-")(1).ToString.Trim

simple isnt it
hope this would help you

Cheers @Karthikeyan34

I will get this input from a mail and i will store this input in a variable
where;
Name in Username variable
Userid in Out_id variable

1 Like

Fine
then we can do one this
–use a get outlook mail activity and get the list ofmail
–we will be using a for each activity and mention the mail list variable as input
–and those two variables are stored in two variables
–before this get outlook mail message we can use a build datatable activity and create a datatable with two string type of columns and get the output with a variable of type dattable named outdt
–now inside the for each loop use a assign activity like this
outdt.Rows(counter)(“yourcolumn1name”) = Username .ToString
outdt.Rows(counter)(“yourcolumn2name”) = Out_id .ToString
–next to this use anothe assign to increment the value of counter
counter = counter + 1
where counter is a int32 variable with default value 0 defined in the variable panel

this will work for sure
Cheers @Karthikeyan34

@Palaniyappan error sir

1 Like

just now modified
sorry typo mistake

Cheers @Karthikeyan34

@Palaniyappan Error: There is no row at position 0

1 Like

no worries
if possible can i have a screenshot of the sequence and error message if possible
Cheers @Karthikeyan34

@Palaniyappan

1 Like

No worries
sorry that i could see the errored out activity
if possible can you kindly share the workflow, with project.json file all together a zipped folder
Cheers @Karthikeyan34