MikeStall / DataTable

Class library for working with tabular data, especially CSV files
Apache License 2.0
150 stars 63 forks source link

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

Open arteny opened 10 years ago

arteny commented 10 years ago

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

MikeStall commented 10 years ago

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

arteny commented 10 years ago

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");
MikeStall commented 9 years ago

RowsAs 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.