Here's my code:
public void DeserialStream(string filePath)
{
using (StreamReader sr = new StreamReader(filePath))
{
string currentline;
Regex countRegex = new Regex("\"DataType\",\"(?:Count|Net)\"((?!\"DataType\").)*", RegexOptions.Singleline);
while ((currentline = sr.ReadLine()) != null)
{
foreach (Match match in countRegex.Matches(currentline))
{
Console.WriteLine(match.Value);
}
}
}
}
Here's my CSV:
"Date","dd/mm/yyyy"
"ExpirationDate","dd/mm/yyyy"
"DataType","Count"
"Location","Unknown","Variable1","Variable2","Variable3"
"A(Loc3, Loc4)","Unknown","5656","787","42"
"A(Loc5, Loc6)","Unknown","25","878","921"
"DataType","Net"
"Location","Unknown","Variable1","Variable2","Variable3"
"A(Loc3, Loc4)","Unknown","5656","787","42"
"A(Loc5, Loc6)","Unknown","25","878","921"
I want to return the data between "DataType", "Count" and "DataType", "Net" below. However, my compiler is returning the terms: "DataType", "Count" and "DataType", "Net" and not the data in between. I'm not sure what I am doing wrong?