更新时间:2023-12-03 19:56:22
您可以通过用,
拆分每行并比较前两列来过滤行.
You could filter the rows by splitting each row with ,
and comparing first two columns.
var nonEmptyLines = File.ReadAllLines(fileName)
.Where(x=> !x.Split(',')
.Take(2)
.Any(cell=> string.IsNullOrWhiteSpace(cell))
// use `All` if you want to ignore only if both columns are empty.
).ToList();
File.WriteAllLines(fileName, nonEmptyLines);