Datatable extracted from web, convert from string to int

Hi All,
I’ve been working on this for ~3 hours without much progress.

I want to extract a list of numbers, and determine the maximum in the list.

Extracting, from the webpage, will keep the numbers as strings, and the max found will be ‘9’, and not ‘64’.
I can ‘for each’ and convert each row and write it out as an int, and write line it, but I actually don’t know if I can find the max from that list (i.e. and if the string > Int actually works)

I tried playing around with a lot of different conversion types, etc, but I always seem to get “cannot be converted” errors and the like.

My file is a bit of a mess, so ignore the areas that simply don’t work, I have commented them out anyway.

Attached is the file.
How is the best, most logical approach to this?

I did try and use BalaReva.DataTable.Activities - convert column data type, but it only seemed to have outputs.

Please assist, I’m going bonkers.

edit: additionally, I would get the error around "Strict Only is On, cannot do " I Am not sure if that is inhibiting me? I notice that it only seems to appear in this “test bed” file.

WebExtractTestBed.xaml (20.4 KB)

@Jroach,

You can convert that to integer list with the following linq query and from that integer list you can find the Max value using max() method

yourListString.ConvertAll(AddressOf Integer.Parse)
2 Likes

I’ll try and convert the data table → column → Listofstring

I actually didn’t get a list, it was just a read output line by line.
I tried to follow this: How to put data from a column of datatable to list of string - #4 by Dominic

( From row in dt.AsEnumerable() Select Convert.Tostring(row(“ColumnName”)) ).ToList()

But I am not having much luck with that variable.

I am getting this error when trying to assign List
image

Hi,

In my opinion you should create System.Collectione.IEnumerable<Of Stirng> and this is your variable with string list. not List<Of String> or You are just missing the definition of the List you are trying to fill.

Moving forward there is no point to using Strings list, go and create list of INT’s or doubles to be precisle.

I would use something like this
newList = New List<Of Double>
newList = ( From row in dt.AsEnumerable() Select Double.Parse(row("ColumnName").ToString)).ToList()

Hello Jeremy,
In this video I filter the text in multiple ways to have a perfect format for Generate DataTable (maybe this will help you):

30:30 Generate DataTable
33:00 Filter data for multiple fake spaces before Generate DataTable
38:20 Filter data with multiple spaces inside of column
Thanks,
Cristian Negulescu