Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TSV - Exception on blank field value #289

Open
jamesflagg opened this issue Jul 11, 2023 · 1 comment
Open

TSV - Exception on blank field value #289

jamesflagg opened this issue Jul 11, 2023 · 1 comment

Comments

@jamesflagg
Copy link

jamesflagg commented Jul 11, 2023

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()
`

@Cinchoo
Copy link
Owner

Cinchoo commented Jul 11, 2023

Applied fix, released v1.2.1.60

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants