这个你可以参考一下,但是没完全实现:
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;
type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
        uses StrUtils;
{$R *.dfm}
function spaceprocess(s:string):string;
var
 T : String;
begin
 T := AnsiReplaceStr(S, ' ',',');
 while T <> S do
 begin
   S := T;
   T := AnsiReplaceStr(S, ' ',',');
 end;
 Result := AnsiReplaceStr(S, ' ',',');
end;
procedure TForm1.Button1Click(Sender: TObject);
var
  myfile:textfile;
  str,str1,str2,str3,str4,str5,str6:string;
begin
  memo1.Clear;
  assignfile(myfile,'E:\AAABBBCCC\myfl.txt');
  reset(myfile);
  while not eof(myfile) do
  begin
  readln(myfile,str1);
  readln(myfile,str2);
  readln(myfile,str3);
  readln(myfile,str4);
  readln(myfile,str5);
  readln(myfile,str6);
  str:=str1+str4+str5;
  memo1.Lines.Add(spaceprocess(str));
  end;
  closefile(myfile);
end;
end. 
效果图: