Saving files fails

Feb 11, 2011 at 12:02 PM

For which ever of the combinations bellow 

'Dim dsNEW As New Microsoft.Research.Science.Data.CSV.CsvDataSet("c:\test.csv")

'Dim dsNEW As DataSet = DataSet.Create("msds:nc?")

Dim dsNew As DataSet = DataSet.Open("msds:memory")


Dim vid As Integer = dsNEW3.AddVariable(Of Single(,))("myvar").ID ' "Not supported type of data."            

dsNEW3.PutData(Of Single(,))(vid, val2d)            

Dim newVar As Variable = dsNEW3.Variables(vid)            


I get the following two exceptions

'"Not supported type of data."

' Variables of type Single[,] are not supported in DataSet 1.0


Any ideas what should i do to correct this problem ?

Feb 17, 2011 at 2:23 PM
Edited Feb 17, 2011 at 2:24 PM


We have two version of API: object model and imperative. In the example you have mixed both APIs.

The DataSet.AddVariable<DataType> method is from object model; and the type parameter DataType is a type of element, i.e. in your example you should specify AddVariable<Single>() instead of AddVariable<Single[,]>(). To specify that new variable is two dimensional, you should provide two dimensions as last parameters of the method:

ds.AddVariable<Single>("var","i","j") // i,j are dimensions names

Imperative API is simpler and is file IO-like (see documentation). It exposes extension methods defined in the assembly Microsoft.Research.Science.Data.Imperative, and its method ds.Add<D> takes a complete data type as D (i.e. Add<Single[,]> in the example):

using Microsoft.Research.Science.Data.Imperative;
ds.Add<Single[,]>("var"); // we may not specify dimensions names here, default names will be used

 Also I would recommend you to take a look at the "Getting Started" document.

With regards,