HeaderRow: Integer;
The HeaderRow property determines the number of row that contains fields headers.
Executing the example requires a time series database with the OBJ_RUBRICATOR identifier and the C:\result.txt time series export file.
Sub Main;
Var
TextProvider: IDtTextProvider;
Provider: IDatasetDataProvider;
Mb: IMetabase;
RubDesc: IMetabaseObjectDescriptor;
CrInfo: IMetabaseObjectCreateInfo;
Obj: IMetabaseObject;
ObjDesc: IMetabaseObjectDescriptor;
ImportRequestDef: IImportRequestDefinition;
ImportRequestProviderParams: IImportRequestProviderParams;
Binding: ICubeMetaLoaderBinding;
Begin
// Data source to import from text format
TextProvider := New DtTextProvider.Create;
TextProvider.File := "C:\result.txt";
TextProvider.FormatType := DtTextFormatType.Delimited;
TextProvider.DelimitedColumnDelimiter := ";";
TextProvider.DelimitedTextQualifier := """";
TextProvider.Encoding := "WIN";
TextProvider.RangeHasHeader := True;
TextProvider.HeaderRow := 2;
TextProvider.AllowMuchColumnDelimiter := True;
TextProvider.Open;
Mb := MetabaseClass.Active;
RubDesc := Mb.ItemById("OBJ_RUBRICATOR");
Provider := (TextProvider As IDatasetDataProvider);
// Import object
CrInfo := Mb.CreateCreateInfo;
CrInfo.ClassId := MetabaseObjectClass.KE_CLASS_IMPORTREQUEST;
CrInfo.Id := "OBJ_IMPORTREQUEST_P";
CrInfo.Name := "Import object";
CrInfo.Permanent := True;
CrInfo.Parent := RubDesc.Bind;
ObjDesc := Mb.CreateObject(CrInfo);
Obj := ObjDesc.Edit;
// Set up provider
ImportRequestDef := Obj As IImportRequestDefinition;
ImportRequestDef.SourceType := ImportRequestSourceType.Provider;
ImportRequestDef.DestinationRubricator := RubDesc.Bind As IRubricator;
// Import parameters
ImportRequestProviderParams := ImportRequestDef.ProviderParams;
ImportRequestProviderParams.Provider := Provider;
ImportRequestProviderParams.NewRevisionName := "Indicators import";
ImportRequestProviderParams.ImportObjectKey := Obj.Key;
ImportRequestProviderParams.LoadType := CubeMetaLoaderLoadType.CreateAndUpdate;
Binding := ImportRequestProviderParams.Bindings.Add;
Binding.BindingType := CubeMetaLoaderBindingType.Calendar;
Binding.CalendarOptions.Levels := DimCalendarLevelSet.Year;
Binding.ByColumns := False;
Binding.CalendarDateFormat := "$Year$";
Obj.Save;
End Sub Main;
After executing the example an object for importing time series from the text file C:\result.txt is created in time series database. In the object calendar parameters are set. During import as a field delimiter symbol quot;;quot; is used, as a text delimiter - double quotes symbol. Delimiters running in succession are skipped. Field names are imported from the second file row.
See also: