I am trying to find if a any element of a first list is found for each line of a csv file
First list :
XX01235756777
YY01215970799
Second list (that would be the csv file) :
Column_1|Column_2|Column_3|Column_4|Column_5|Column_6|Column_7
VX|2022-06-09 11:50:55|Y|Y|N|TT56431254135|Microsoft
VX|2022-06-09 11:50:55|Y|Y|N|XX01235756777|Meta
VX|2022-06-09 11:50:55|Y|Y|N|YY18694654355|Nokia
VX|2022-06-09 11:50:55|Y|Y|N|OO01215970799|BlackStone
VX|2022-06-09 11:50:55|Y|Y|N|YY01215970799|Alphabet
My code attempt :
List<string> filteredList = new List<string>();
using (StreamReader reader = new StreamReader(csvFilePath))
{
string line;
while ((line = reader.ReadLine()) != null)
{
if (line.Any(x => isinList.Contains(x.ToString())))
{
filteredList.Add(line);
}
}
}
return filteredList;
filteredList should be :
VX|2022-06-09 11:50:55|Y|Y|N|XX01235756777|Meta
VX|2022-06-09 11:50:55|Y|Y|N|YY01215970799|Alphabet
I succeeded at finding a single element in each line of the csv file.
But I can't code the right LINQ to process if whole list is present in each line.
Any ideas or anywhere you can point me to would be a great help.