I believe that it is best to fix the library yourself.
The problem is that the Read
method uses the SkipEmptyRecords
parameter and the IsRecordEmpty
method to determine whether it should skip the field or not:
while (this.configuration.SkipEmptyRecords && this.IsRecordEmpty(false));
However, the IsRecordEmpty () method is not ideally implemented to support your script, as it uses the following code:
Enumerable.All<string>((IEnumerable<string>) this.currentRecord, new Func<string, bool>(string.IsNullOrEmpty));
This does not work because your lines are not null or empty. In my opinion, combining Trimming with SkipEmptyRecords could work theoretically:
csv.Configuration.TrimFields = true; csv.Configuration.SkipEmptyRecords = true;
But again, cropping is not used to check if the field is empty or not, so Iām sure that your only option is to fix the library yourself and use the cropping in the IsRecordEmpty () method or use IsNullOrWhiteSpace instead of IsNullOrEmpty.
source share