I would like to compare it to another CSV (table2) that contains the KEYVALUE portion of the description, and return the associated state. Layout of table2:
State | Description
AL | ALKEYVALUE*
AK | AKKEYVALUE*
The only way I can think of making this work is to nest 2 for each loops where it goes through each row of table1, and then compares it to each row in table2. However, this seems very inefficient. Is there a better way of doing this?
Compare first 10 characters from Table A Description and Table B description which is XXKEYVALUE. The output will have Table A description and Table B State into a DataTable.
dtJoin=(From a In dt1.AsEnumerable() Join b In dt2.AsEnumerable() On a.Field(Of String)(“Description”).ToString.SubString(0,10) Equals b.Field(Of String)(“Description”).ToString.SubString(0,10) Select dtJoin.LoadDataRow(New Object() {a.Field(Of String)(“Description”),b.Field(Of String)(“State”)}, False)).CopyToDataTable
Hey, how do we get all the columns for both the tables in this case?
Something like this using {a,b} -
dtJoin=(From a In dt1.AsEnumerable() Join b In dt2.AsEnumerable() On a.Field(Of String)(“Description”).ToString.SubString(0,10 ) Equals b.Field(Of String)(“Description”).ToString.SubString(0,10) Select dtJoin .LoadDataRow(New Object() {a,b}, False)).CopyToDataTable