Topic: SaveToTextFile
I am using the SaveToTextFile method. I want to include a header row, can this be achieved?
Robb
My Visual Database → Script → SaveToTextFile
I am using the SaveToTextFile method. I want to include a header row, can this be achieved?
Robb
I am using the following commands
FrmExport.TableGrid1.SaveToTextFile(SaveDialog.Filename);
and
Frmexport.Memo1.Lines.savetofile(ExtractFileDir(SaveDialog.Filename)+'\'+'headerrow.csv');
I am then trying to concatenate the two files. The headerrow file is showing as strange characters when concatenated with the textfile.
Are these two commands writing to the same character set? Each file visually looks ok, but when I combine then using TFileStream the header file is not readable. See attachement https://www.dropbox.com/s/k2kzovxz1cnz6 … 6.pdf?dl=0
Thank you,
Robb
Please attach your project.
Sample.zip
The project generates three files:
sample_export.csv which comes from my main table
headerrow.csv which comes from the header row
fOutfile.csv which is my combined file - which does not transform nicely.
My procedure ConcatenateFiles does the final output.
Thanks for your assistance.
rjkantor
Try this procedure:
Procedure ConcatenateFiles(const InFileNames: array of string; const OutFileName: string);
var
i: Integer;
InStream, OutStream: TStringList;
begin
OutStream:= TStringList.Create;
try
for i := 0 to length(InFileNames)-1 do
begin
InStream := TStringList.Create;
InStream.LoadFromFile(InFileNames[i]);
try
OutStream.Text := OutStream.Text + InStream.Text;
finally
InStream.Free;
end;
end;
OutStream.SaveToFile(OutFileName);
finally
OutStream.Free;
end;
end;
Thank you. That worked.
My Visual Database → Script → SaveToTextFile
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi