Can we check for a part of string in hashtable key? For example, our key is
I know have a function called containskey() but do we have something that could partially check for a string in a hashtable key?
For example, if we could search
My problem statement
I have two .csv files -
File1
The Access Details column contains details as ``CardNumber|SecretPin|TokenNumber```
Same is the File2
I have to compare these two files, my conditions are -
This is how I am storing values of File1
In the simiar fashion,I am storing the contents of file2 in a different hashtable. Then I am doing the following to read file2 data and compare
I was wondering of perhaps I should store key as
and then perhaps do something that could search if a token Id or a cardnumber is present in this key or not. because in the above approach, I can test if the cardnumber is present or not because it is the key in both Files, but this approach will fail if we have different cardnumbers and same token number(row 1 in the example table)
Secondly, I dont know how to deal with the null value column as there are no unique linking values for these records.
P.S - I don't own the data. I can't change it.
C#:
key = residentnumber +","+ housenumber
I know have a function called containskey() but do we have something that could partially check for a string in a hashtable key?
For example, if we could search
C#:
if(key.cotains(housenumber))
My problem statement
I have two .csv files -
File1
C#:
EmployeeId Username BranchId NewJoinee EmpType AccessDetails
5543101 abc.username 40000 0 64 60060||60060
5543102 someone.username 40000 0 64 52474||52474
5543103 ABC.someone 40000 0 NULL NULL
5543104 XZ.someone 40000 0 64 pppA082||
The Access Details column contains details as ``CardNumber|SecretPin|TokenNumber```
Same is the File2
C#:
EmployeeId Username BranchId NewJoinee EmpType AccessDetails
5000101 abc.username 40500 0 64 5555||60060
5000102 someone.username 40500 0 64 52474||1234
5000103 ABC.someone 40500 0 NULL NULL
5000104 XZ.someone 40500 0 64 10A082||5644
I have to compare these two files, my conditions are -
- If the card number matches but token Id doesn't, do nothing
- If the card number does not match but token Id matches, do nothing
- If the access details are null, then print this employee details to another file
- If both card number and token Id do not match, then print this employee details to another file
This is how I am storing values of File1
C#:
if (!_File1.ContainsKey(cardnumber))
_File1.Add(cardnumber, username + "," + branchId + "," + employeeID + "," + cardnumber + "," + tokennumber + "," + empType + "," + newJoinee);
In the simiar fashion,I am storing the contents of file2 in a different hashtable. Then I am doing the following to read file2 data and compare
C#:
//readingFile2 data
row = SplitCSV(line);
employeeID = row[employeeIndex].Trim().ToString();
username = row[UsernameIndex].Trim().ToString();
branchID = row[branchIdIndex].Trim().ToString();
newJoinee = row[njIndex].Trim().ToString();
emptype = row[emptypeIdIndex].Trim().ToString();
accessdetails = row[ValueIndex].Trim().ToString();
if (!accessdetails.Equals("NULL"))
{
string[] values = value.Split('|');
cardnumberfile2 = values[0];
tokenumberFile2 = values[2];
}
else
{
cardnumberfile2 = employeeID;
tokennumberfile2 = "";
}
if(_file1.ContainsKey(cardnumberfile2))
{
//reading values from File1
// As cardnumber in file2 is present in the file1, then do nothing
}
I was wondering of perhaps I should store key as
C#:
key = cardnumber + "," + tokennumber
and then perhaps do something that could search if a token Id or a cardnumber is present in this key or not. because in the above approach, I can test if the cardnumber is present or not because it is the key in both Files, but this approach will fail if we have different cardnumbers and same token number(row 1 in the example table)
Secondly, I dont know how to deal with the null value column as there are no unique linking values for these records.
P.S - I don't own the data. I can't change it.