How can I delete a row which contains null values from a comma separated csv file in c# ?
Example:
| FirstName | LastName | Email | Address |
|---------------------|------------------|---------------|--------------|
| lmn | lmn |[email protected] |DemoAddress |
| xy | xy |[email protected] |DemoAddress |
| demo | demo | | |
| demo2 | demo2 |[email protected] |DemoAddress |
Outcome:
| FirstName | LastName | Email | Address |
|---------------------|------------------|---------------|--------------|
| lmn | lmn |[email protected] |DemoAddress |
| xy | xy |[email protected] |DemoAddress |
| demo2 | demo2 |[email protected] |DemoAddress |
I tried the following code but doesn't work as expected
private string filterCSV(string strFilePath)
{
var columnIndex = 3;
var line = File.ReadAllLines(strFilePath);
var n = line.Where(x => x[columnIndex].Equals(""));
string result = string.Join("\r", not.ToArray());
return result;
}