TextCodePage: CodePage;
TextCodePage: Prognoz.Platform.Interop.ForeSystem.CodePage;
The TextCodePage property determines the encoding used on data import from file.
To determine the file, from which data is imported, use the IDtTextProvider.File property.
Executing the example requires that repository contains an ETL task with the ETL identifier and the C:\Data.txt text file.
Add links to the Metabase, Etl, Dt, Andy, Drawing system assemblies.
Sub UserProc;
Var
MB: IMetabase;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
TextProvider: IDtTextProvider;
DateFormat: IDtObjectDataFormat;
WxProvider: IWxRectangle;
WxETLProvider: IWxETLObject;
Begin
MB := MetabaseClass.Active;
EtlTask := MB.ItemById("ETL").Edit As IEtlTask;
//Create the Import from Text object
EtlProvider := EtlTask.Create(EtlObjectType.PlainDataTextProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit;
EtlProvider.Id := "Text_Provider";
EtlProvider.Name := "Import from Text";
EtlProvider.Description := "Import from Text";
//Data source setting
TextProvider := EtlProvider.Provider As IDtTextProvider;
TextProvider.File := "C:\Data.txt";
TextProvider.RangeHasHeader := True;
TextProvider.RowDelimiter := "|";
TextProvider.DelimitedColumnDelimiter := ";";
TextProvider.FieldsFromFile;
TextProvider.TextCodePage := CodePage.UTF7;
DateFormat := TextProvider.StringDataFormat;
DateFormat.DateFormat := "DD/MM/YYYY";
DateFormat.DecimalDelimiter := ".";
EtlProvider.FillDefault;
//Save source
EtlProvider.Save;
//Create a visual object
WxProvider := EtlTask.Workspace.CreateRectangle;
WxETLProvider := New WxETLObject.Create;
WxETLProvider.ETLObject := EtlProvider;
WxProvider.Style.TextPosition := WxTextPosition.Bottom;
WxProvider.Style.PictureMarginTop := -10;
WxProvider.PinPosition := New GxPointF.Create(50, 50);
WxProvider.Extension := WxETLProvider As IWxShapeExtension;
//Save Etl task
(EtlTask As IMetabaseObject).Save;
End Sub UserProc;
After executing the example the Import from text object is created in the ETL task. The object imports data from the C:\Data.txt text file with specified settings:
The | character is used as a string separator
The ; character is used as a field separator
Used encoding UTF7 - Unicode UTF-7.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Etl;
Imports Prognoz.Platform.Interop.ForeSystem;
Imports Prognoz.Platform.Interop.Metabase;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
EtlTask: IEtlTask;
EtlProvider: IEtlPlainDataProvider;
TextProvider: IDtTextProvider;
DateFormat: IDtObjectDataFormat;
WxProvider: IWxRectangle;
WxETLProvider: IWxETLObject;
PinPosition: GxPointF = New GxPointFClass();
Begin
MB := Params.Metabase;
EtlTask := MB.ItemById["ETL"].Edit() As IEtlTask;
//Create the Import from Text object
EtlProvider := EtlTask.Create(EtlObjectType.eotPlainDataTextProvider) As IEtlPlainDataProvider;
EtlProvider := EtlProvider.Edit();
EtlProvider.Id := "Text_Provider";
EtlProvider.Name := "Import from Text";
EtlProvider.Description := "Import from Text";
//Data source setting
TextProvider := EtlProvider.Provider As IDtTextProvider;
TextProvider.File := "C:\Data.txt";
TextProvider.RangeHasHeader := True;
TextProvider.RowDelimiter := "|";
TextProvider.DelimitedColumnDelimiter := ";";
TextProvider.FieldsFromFile();
TextProvider.TextCodePage := CodePage.cpUTF7;
DateFormat := TextProvider.StringDataFormat;
DateFormat.DateFormat := "DD/MM/YYYY";
DateFormat.DecimalDelimiter := ".";
EtlProvider.FillDefault();
//Save source
EtlProvider.Save();
//Create a visual object
WxProvider := EtlTask.Workspace.CreateRectangle();
WxETLProvider := New WxETLObject.Create();
WxETLProvider.ETLObject := EtlProvider;
WxProvider.Style.TextPosition := WxTextPosition.wtpBottom;
WxProvider.Style.PictureMarginTop := -10;
PinPosition := WxProvider.PinPosition;
PinPosition.Create(50, 50);
WxProvider.Extension := WxETLProvider As IWxShapeExtension;
//Save Etl task
(EtlTask As IMetabaseObject).Save();
End Sub;
See also: