DataTable icon indicating copy to clipboard operation
DataTable copied to clipboard

[DataAccess.AssertException] = {"Row 1 does not have the expected number of values (0)"}

Open arteny opened this issue 11 years ago • 3 comments

This exception occurs for line: var table = DataTable.New.FromEnumerable(Data); where Data is not empty List of dynamic

arteny avatar Apr 27 '14 15:04 arteny

Can you give me a specific expression for Data? I can make that into a test case and fix.

MikeStall avatar Apr 27 '14 15:04 MikeStall

There is no any specific. I suppose the simplest example is:

var Data = new List<dynamic>();
Data.Add(new{1});

I used it as

            Data = DataTable.New.ReadCsv("data.csv").RowsAs<dynamic>().ToList();
            Data.Add(new
            {data1, data2, ...});
            DataTable.New.FromEnumerable(Data).SaveCSV(@".\data.csv");

arteny avatar Apr 27 '14 16:04 arteny

RowsAs<T> requires T be strongly typed so that it can infer the columns. It can't do that from dynamic. So this may be by-design, although we could have a better error message.

MikeStall avatar Oct 18 '15 04:10 MikeStall