ChoETL icon indicating copy to clipboard operation
ChoETL copied to clipboard

TSV - Exception on blank field value

Open jamesflagg opened this issue 2 years ago • 1 comments

Unit test to reproduce the problem: `

public class ChoTests
{
    [Fact]
    public void CanReadTabDelimitedWithBlankFieldValue()
    {
        using (var reader = ChoTSVReader.LoadText("A\t\tB").ErrorMode(ChoErrorMode.ThrowAndStop))
        {
            foreach(var record in reader)
            {
                Assert.NotNull(record);
                Assert.Equal("A", record.Column1);
                Assert.Null(record.Column2);
                Assert.Equal("B", record.Column3);
            }
        }
    }
}

`

This throws an exception, when it should gracefully populate the record. It is apparently a side effect of the delimiter (tab) being considered whitespace. Stack trace: `

at ChoETL.ChoUtility.RightOf(String source, String searchText) at ChoETL.ChoCSVRecordReader.GetFieldValues(String line) at ChoETL.ChoCSVRecordReader.FillRecord(Object rec, Tuple2 pair) at ChoETL.ChoCSVRecordReader.LoadLine(Tuple2 pair, Object& rec) at ChoETL.ChoCSVRecordReader.AsEnumerable(Object source, TraceSwitch traceSwitch, Func2 filterFunc)+MoveNext() at ChoETL.ChoEnumeratorWrapper.BuildEnumerable[T](Func1 moveNext, Func1 current, Action dispose)+MoveNext() `

jamesflagg avatar Jul 11 '23 02:07 jamesflagg

Applied fix, released v1.2.1.60

Sample fiddle: https://dotnetfiddle.net/9kp7Aw

Cinchoo avatar Jul 11 '23 20:07 Cinchoo