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

ChoCSVWriter - No Header Output When Using WriteFields #320

Open
jamesflagg opened this issue Jun 19, 2024 · 2 comments
Open

ChoCSVWriter - No Header Output When Using WriteFields #320

jamesflagg opened this issue Jun 19, 2024 · 2 comments
Labels

Comments

@jamesflagg
Copy link

When using WriteFields as a shorthand for writing records without a record object, it seems that no header is written, even though one has been designated. Is this the expected behavior, or should it be consistent with writing records using record objects?
Note that the non-header records are written as expected.

public class ChoWriterTest {       [Fact]       public void WriteHeaderAndFields()       {             using var writer = new StringWriter();             using var choWriter = new ChoCSVWriter(writer).WithFirstLineHeader();             choWriter.WriteHeader("A", "B");             choWriter.WriteFields("A1", "B1");             choWriter.WriteFields("A2", "B2");             choWriter.Flush();             writer.Flush();             var result = writer.ToString();             Assert.StartsWith("A,B", result);       } }

@jamesflagg
Copy link
Author

Apologies for mangled formatting. Failing test is as follows. Result starts with "A1," instead of "A,", indicating that the header line is not written.

public class ChoWriterTest
{
            [Fact]
            public void WriteHeaderAndFields()
            {
                        using var writer = new StringWriter();
                        using var choWriter = new ChoCSVWriter(writer).WithFirstLineHeader();
                        choWriter.WriteHeader("A", "B");
                        choWriter.WriteFields("A1", "B1");
                        choWriter.WriteFields("A2", "B2");
                        choWriter.Flush();
                        writer.Flush();
                        var result = writer.ToString();
                        Assert.StartsWith("A,B", result);
            }
}

@Cinchoo Cinchoo added the bug label Jun 19, 2024
@Cinchoo
Copy link
Owner

Cinchoo commented Jun 19, 2024

its a bug, applying fix. will release shortly.

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

No branches or pull requests

2 participants