DelimitedColumnDelimiters: Array;
The DelimitedColumnDelimiters property determines the rows array, used as a field delimiter in the text file.
As an array elements the following values are acceptable:
,
;
.
:
|
{Tabulation} - code #9
{Carriage return} - code #13
{Row transfer} - code #10
{Carriage return}{Row transfer} - #13+#10
Any other symbol, or a combination of symbols, optional for user.
If any symbol from the array coincides with DelimitedTextQualifier or RowDelimiter property value, it is not regarded as a field separator.
Executing the example requires a text file C:\Test.txt. There are four fields in the file, separated with the ;, : and ! symbols (semicolon, colon, and exclamatory mark).
Text of the C:\Test.txt file, for which the example is written
Sub Main;
Var
TextProv: IDtTextProvider;
TextCons: IDtTextConsumer;
DelimArr: Array[0..2] Of String;
Begin
TextProv := New DtTextProvider.Create;
TextCons := New DtTextConsumer.Create;
TextProv.File := "C:\Test.txt";
TextProv.RangeHasHeader := True;
DelimArr[0] := ";";
DelimArr[1] := ":";
DelimArr[2] := "!";
TextProv.DelimitedColumnDelimiters := DelimArr;
TextProv.GetFieldsFromFile;
TextCons.File := "C:\Test_result.txt";
TextCons.WriteHeader := True;
TextCons.Fields.Add;
TextCons.Fields.Add;
TextCons.Fields.Add;
TextCons.Fields.Add;
TextCons.PutProvider(TextProv);
End Main;
After executing the example data from the file C:\Test.txt is loaded into the file C:\Test_result.txt, with symbol "," as fields delimiter.
Text of the C:\Test_result.txt file, which is obtained after executing the example
See also: