Matching id with ignoring 1 character

hi. i want to match id from dt1 and dt2
i want to match them while ignoring 1 character in the id.
the dt1 ids have (‘) in the end.
the reason why i put (’) in the id in dt1 cause the excel auto change the ids after my first output.

Hi,

We can achieve this using TrimEnd method, as the following, for example.

newDt = dt1.AsEnumerable.Where(Function(r) dt2.AsEnumerable.Any(Function(r2) r2("id").ToString=r("id").ToString.TrimEnd("'"c))).CopyToDataTable

Regards,

will this remove permanent the (‘) in the dt1?
i need the (’) in the whole process.

this is my way of comparing ids
findrow = MSMEDT.AsEnumerable.Where(Function(x) x(3).ToString.Equals(currentrow(7).ToString)).FirstOrDefault()

Nope, it just evaluates string which is removed ' character. Data isn’t updated.

findrow = MSMEDT.AsEnumerable.Where(Function(x) x(3).ToString.Equals(currentrow(7).ToString)).FirstOrDefault()

Which is dt1 you said in the first post? (MSMEDT or datatable for currentrow?)

Regards,

the currentrow is the one the have special character

Hi,

All right. Can you try the following expression?

findrow = MSMEDT.AsEnumerable.Where(Function(x) x(3).ToString.Equals(currentrow(7).ToString.TrimEnd("'"c)).FirstOrDefault()

Regards,

hi. it works. but i wonder why other ids still can’t match
image
those id that i highlighted matched but the ids on the top can’t match.

i manually checked the dt1 and dt2 and both ids are in there.

Hi,

Can you share actual data?

Regards,

im sorry it’s confidential.

the dt1 is .csv and the dt2 is .xlsx

but i manually checked both files. the ids are there. :frowning:

im having a hard time. cause some of my process is matching id. i’ve been stock in this issue since last week huhu.

Hi,

For now, can you export worksheet of dt2 to csv file, then compare both record using text editor?
There might be something diffrence such as whitespace etc.

Regards,

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