Assigning values for final row of a data table

Hi All,

I have scraped some data from a web application and it appears as below:
image

The number of rows may change from time to time but the ‘Net Unexplained Difference’ will always be the last row. How would I extract and assign the highlighted values?

Hello @chend

var CCY2-USD = dt.select(“Column-0 like ‘%Net Unexplained Difference%’”)(0)(“Accounted CCY2 USD”).ToString

var CCY2-AUF = dt.select(“Column-0 like ‘%Net Unexplained Difference%’”)(0)(“Accounted CCY2 AUD”).ToString

for more help on DataTable.Select refer below link

Hi Askshay,

Thank you for the comment, this definitely will be useful.

I have created a work around:

1.To scrape only the 'Net Unexplained Difference" row only
2.This transposes the data into a column, where the ‘Net Unexplained Difference’ becomes the first row of the data.
3.Removed the first row of data.

@chend

Let us take you scraped data and stored in a datatable dta

As you told your required value will be always in Last row.

strAccountedCCY2USD= dta.Rows(dta.Rows.Count-1)(“Accounted CCY2 USD”).ToString

strAccountedCCY2AUD= dta.Rows(dta.Rows.Count-1)(“Accounted CCY2 AUD”).ToString

Regards,
Mahesh

This would be great but the currency can vary e.g. NZD, USD, AUD and so forth.
Would it be possible to replace the currency with *?

E.g. strAccountedCCY2= dta.Rows(dta.Rows.Count-1)(“Accounted CCY2*”).ToString

Regards,

Darren

@chend

If the column Index remains same then use column index instead of column Name.

strAccountedCCY2USD= dta.Rows(dta.Rows.Count-1)(1).ToString

strAccountedCCY2AUD= dta.Rows(dta.Rows.Count-1)(2).ToString

Regards,
Mahesh

3 Likes

Hi Mahesh1,

Thank you for the assistance. This worked out great.

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