Data table column into variable

Hi,

How to extract the specific column form web scraped datatable and assign it into a array of variable.
thanks in advance!

Hi @Dheena_Kumar,

Convert.ToString(Datatable.rows(0)("Column name"))

(From row in dt select row("ColumnName")).ToArray()

Regards,
Arivu

2 Likes

Hi @arivu96

can you please elaborate, that does not seem to work for me, throws me an error

this is what i am trying to do:

i am trying to take the first column, the item no in dt to an array variable, the variable should contain all the values inside, as the data from datatable differs for each workflow.
Please help

Thanks!
Deena

His solution is basically taking your scraped data table and using LINQ to extract only the first column that you desired.

So basically you would end up doing something like this:

Extract Structured Data // let's call dt1
Assign items = dt1.AsEnumerable.Select(Function(r) r(0).ToString.Trim).ToArray 

(or with column name: dt1.AsEnumerable.Select(Function® r(“ITEM NO”).ToString.Trim).ToArray

Similarly you can use LINQ like this:

(From r In dt1.AsEnumerable Select r(0).ToString.Trim).ToArray

I think one of these will be the fast method to getting your column to an array of strings.

If you are wanting a different array or something, let us know.

Thanks.

1 Like

@ClaytonM

cool, it worked like champ.
Thanks man

Deena