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

FieldCount not increased when Adding custom column #58

Open
codermel opened this issue Jul 10, 2018 · 0 comments
Open

FieldCount not increased when Adding custom column #58

codermel opened this issue Jul 10, 2018 · 0 comments
Labels

Comments

@codermel
Copy link

While I can get this sample code to print out the value of my custom column correctly, it does not work with SBC. SBC will not see my new column.

Working sample code:
`
using (StreamReader file = new StreamReader(_workingFile))
{
using (CsvReader csv = new CsvReader(file, true, '\t'))
{
csv.GetFieldHeaders();

                csv.Columns.Add(new LumenWorks.Framework.IO.Csv.Column { Name = "Record_Date_UTC", Type = typeof(string) });
                csv.UseColumnDefaults = true;
                csv.Columns.Where(x => x.Name == "Record_Date_UTC").FirstOrDefault().DefaultValue = "Blah";
                int fieldCount = csv.FieldCount;
                fieldCount++; // Having to manually increase this by 1 to account for custom column

                string[] headers = csv.GetFieldHeaders();
                
                while (csv.ReadNextRecord())
                {
                    for (int i = 0; i < fieldCount; i++)
                        Console.Write(string.Format("{0} = {1};",
                                      headers[i], csv[i]));
                    Console.WriteLine();
                }
            }
        }

SBC code throws "System.ArgumentException: 'Record_Date_UTC' field header not found.":

                    using (CsvReader csv = new CsvReader(file, true, '\t'))
                    {
                        csv.GetFieldHeaders();
                        csv.Columns.Add(new LumenWorks.Framework.IO.Csv.Column { Name = "Record_Date_UTC", Type = typeof(DateTime) , DefaultValue = fileDate.ToShortDateString() });
                        csv.UseColumnDefaults = true;
                        var fieldCound = csv.FieldCount;

}
`

@phatcher phatcher added the bug label Aug 9, 2018
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