ICubeMetaLoaderBinding.HeaderParser

Syntax

HeaderParser: ICubeMetaLoaderBindingParser;

Description

The HeaderParser property returns the object that enables the user to recognize attributes from the columns headers in a data source.

Example

Executing the example requires a time series database with the OBJ_FC identifier and the time series export file C:\Delimited.txt. Also, the repository must contain an MDM repository with the MDM_REPO identifier. This repository should have dictionaries with the DICT_CTR, DICT_IND and UNITS identifiers. The COUNTRY attribute of the time series database refers to the DICT_CTR dictionary, the INDICATOR attribute is a link to the DICT_IND dictionary, and measurement units refer to the UNITS dictionary.

The C:\Delimited.txt file, for which the example is created:

Sub Main;

Var

Mb: IMetabase;

NsiDescr: IMetabaseObjectDescriptor;

CubeMetaLoader: ICubeMetaLoader;

CrInfo: IMetabaseObjectCreateInfo;

Obj: IMetabaseObject;

ObjDesc: IMetabaseObjectDescriptor;

CubeMetaLoaderBindings: ICubeMetaLoaderBindings;

CalendarBinding: ICubeMetaLoaderBinding;

CountryBinding: ICubeMetaLoaderBinding;

IndicatorBinding: ICubeMetaLoaderBinding;

UnitBinding: ICubeMetaLoaderBinding;

LevelBinding: ICubeMetaLoaderBinding;

ValueBinding: ICubeMetaLoaderBinding;

HeaderParser: ICubeMetaLoaderBindingParser;

Parser: ICubeMetaLoaderBindingParser;

Text: DtTextProvider;

Provider: IDatasetDataProvider;

Log: ICubeMetaLoaderLog;

Entry: ICubeMetaLoaderLogEntry;

Count, i: Integer;

Begin

Mb := MetabaseClass.Active;

NsiDescr := Mb.ItemById("RDS_REPO");

 

CrInfo := Mb.CreateCreateInfo;

CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_CUBEMETALOADER;

CrInfo.Id := "CUBEMETALOADER";

CrInfo.Permanent := False;

ObjDesc := Mb.CreateObject(CrInfo);

Obj := ObjDesc.Edit;

CubeMetaLoader := Obj As ICubeMetaLoader;

CubeMetaLoader.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;

CubeMetaLoader.Rubricator := Mb.ItemById("OBJ_FC").Bind As IRubricator;

CubeMetaLoaderBindings := CubeMetaLoader.Bindings;

 

CountryBinding := CubeMetaLoaderBindings.Add;

CountryBinding.BindingType := CubeMetaLoaderBindingType.Attribute;

CountryBinding.Attribute := "COUNTRY";

CountryBinding.Dimension := Mb.ItemByIdNamespace("DICT_CTR", NsiDescr.Key).Bind As IDimensionModel;

// IX_WEO - is a dictionary DICT_CTR unique key

CountryBinding.Index := "IX_WEO";

CountryBinding.KeyAttribute := "KEY";

CountryBinding.FieldType := CubeMetaLoaderFieldType.Index;

CountryBinding.Field := "0";

HeaderParser := CountryBinding.HeaderParser;

HeaderParser.ParserType := CubeMetaLoaderParserType.Delimited;

HeaderParser.DelimiterChars := "|";

HeaderParser.DelimitedPosition := 0;

Parser := CountryBinding.Parser;

Parser.ParserType := CubeMetaLoaderParserType.Delimited;

Parser.DelimiterChars := "|";

Parser.DelimitedPosition := 0;

 

IndicatorBinding := CubeMetaLoaderBindings.Add;

IndicatorBinding.BindingType := CubeMetaLoaderBindingType.Attribute;

IndicatorBinding.Attribute := "INDICATOR";

IndicatorBinding.Dimension := Mb.ItemByIdNamespace("DICT_IND", NsiDescr.Key).Bind As IDimensionModel;

// IX_CODE - is a dictionary DICT_IND unique key

IndicatorBinding.Index := "IX_CODE";

IndicatorBinding.KeyAttribute := "KEY";

IndicatorBinding.FieldType := CubeMetaLoaderFieldType.Index;

IndicatorBinding.Field := "0";

HeaderParser := IndicatorBinding.HeaderParser;

HeaderParser.ParserType := CubeMetaLoaderParserType.Delimited;

HeaderParser.DelimiterChars := "|";

HeaderParser.DelimitedPosition := 2;

Parser := IndicatorBinding.Parser;

Parser.ParserType := CubeMetaLoaderParserType.Delimited;

Parser.DelimiterChars := "|";

Parser.DelimitedPosition := 2;

 

CalendarBinding := CubeMetaLoaderBindings.Add;

CalendarBinding.BindingType := CubeMetaLoaderBindingType.Calendar;

CalendarBinding.CalendarOptions.Levels := DimCalendarLevelSet.Year;

CalendarBinding.ByColumns := False;

CalendarBinding.CalendarDateFormat := "$Year$";

CalendarBinding.FieldType := CubeMetaLoaderFieldType.Index;

CalendarBinding.Field := "0";

HeaderParser := CalendarBinding.HeaderParser;

HeaderParser.ParserType := CubeMetaLoaderParserType.Delimited;

HeaderParser.DelimiterChars := "|";

HeaderParser.DelimitedPosition := 4;

Parser := CalendarBinding.Parser;

Parser.ParserType := CubeMetaLoaderParserType.Delimited;

Parser.DelimiterChars := "|";

Parser.DelimitedPosition := 4;

 

ValueBinding := CubeMetaLoaderBindings.Add;

ValueBinding.BindingType := CubeMetaLoaderBindingType.Value;

ValueBinding.FieldType := CubeMetaLoaderFieldType.Index;

ValueBinding.Field := "0";

HeaderParser := ValueBinding.HeaderParser;

HeaderParser.ParserType := CubeMetaLoaderParserType.Delimited;

HeaderParser.DelimiterChars := "|";

HeaderParser.DelimitedPosition := 5;

Parser := ValueBinding.Parser;

Parser.ParserType := CubeMetaLoaderParserType.Delimited;

Parser.DelimiterChars := "|";

Parser.DelimitedPosition := 5;

 

LevelBinding := CubeMetaLoaderBindings.Add;

LevelBinding.BindingType := CubeMetaLoaderBindingType.Attribute;

LevelBinding.Attribute := "DL";

LevelBinding.FieldType := CubeMetaLoaderFieldType.ConstValue;

LevelBinding.FieldValue := DimCalendarLevel.Year As Integer;

 

UnitBinding := CubeMetaLoaderBindings.Add;

UnitBinding.BindingType := CubeMetaLoaderBindingType.Unit;

UnitBinding.FieldType := CubeMetaLoaderFieldType.ConstValue;

UnitBinding.FieldValue := 3535 As Variant;

UnitBinding.Dimension := Mb.ItemByIdNamespace("UNITS", NsiDescr.Key).Bind As IDimensionModel;

 

Text := New DtTextProvider.Create;

Text.File := "C:\Delimited.txt";

Text.Encoding := "WIN";

Text.FormatType := DtTextFormatType.Fixed;

Text.RangeHasHeader := True;

Text.Open;

Provider := New DatasetDataTransformProvider.Create;

Provider := Text As IDatasetDataProvider;

 

CubeMetaLoader.Data := Provider;

CubeMetaLoader.LoadData;

Log := CubeMetaLoader.Log;

Count := Log.Count;

Debug.WriteLine("Total number of records in the log: " + Count.ToString);

For i := 0 To Count - 1 Do

Entry := Log.Item(i);

Debug.WriteLine(i.ToString + " : "

+ Entry.DateBegin.ToString + ","

+ Entry.RecordNumber.ToString + ","

+ Entry.Field + ","

+ Entry.ErrorMessage);

If i >= 10 - 1 Then

Break;

End If;

End For;

End Sub Main;

After executing the example factors from the C:\Delimited.txt file are exported. Attributes are recognized from the list with dividers.

See also:

ICubeMetaLoaderBinding