Text File Importer
Functions to import from text files of various formats.
Object Definition
Object Type | Codeunit |
Object ID | 70327087 |
Object Name | QWETB Text File Importer |
Procedures
Deprecated Procedures
Example
Import from an UTF8 encoded file with Tab as a field separator.
TempFileSettings.Init();
TempFileSettings.Encoding := TempFileSettings.Encoding::UTF8;
TempFileSettings."Data Type" := TempFileSettings."Data Type"::Delimited;
TempFileSettings.Delimiter := TempFileSettings.Delimiter::Tab;
TextFileImporter.LoadData(TempFileSettings, TempBlob);
while TextFileImporter.GetTextLine(FieldList) do begin
LineNo += 1;
for FieldNo := 1 to FieldList.Count() do begin
if not Confirm('Line %1, Column %2: %3', true, LineNo, FieldNo, FieldList.Get(FieldNo)) then
error('');
end;
end;
Import data from an UTF8 encoded file with Tab as a field separator to a table named Import Buffer. Skip first line if File Settings is configured with "Column Headers" = true
local procedure ImportTextFileToImportBuffer(TempBlob: Codeunit "Temp Blob"): Boolean
var
ImportBuffer: Record "Customer Update Buffer";
TempFileSettings: Record "QWETB File Settings" temporary;
TextFileImporter: Codeunit "QWETB Text File Importer";
LineNo: Integer;
n: Integer;
ImportMsg: Label '%1 lines have been imported.', Comment = '%1 = Number of Lines';
begin
TempFileSettings.Init();
TempFileSettings.Encoding := TempFileSettings.Encoding::UTF8;
TempFileSettings."Data Type" := TempFileSettings."Data Type"::Delimited;
TempFileSettings.Delimiter := TempFileSettings.Delimiter::Tab;
TempFileSettings."Column Headers" := true;
TextFileImporter.LoadData(TempFileSettings, TempBlob);
for LineNo := 1 to TextFileImporter.GetNumberOfLines() do begin
if (LineNo = 1) and TempFileSettings."Column Headers" then begin
; // Skip first line if it contains column headers
end else begin
ImportBuffer.Init();
ImportBuffer.Field1 := TextFileImporter.GetFieldValue(LineNo, 1);
ImportBuffer.Field2 := TextFileImporter.GetFieldValue(LineNo, 2);
ImportBuffer.Field3 := TextFileImporter.GetFieldValue(LineNo, 3);
ImportBuffer.Field4 := TextFileImporter.GetFieldValue(LineNo, 4);
ImportBuffer.Insert(true);
n += 1;
end;
end;
Message(ImportMsg, n);
end;
This documentation is generated from Smart Toolbox v27.0