也可把后两个合并后
用SplitString(str,',')分割后再处理///分割一个字符串,其中分割的标志是ch
function SplitString(const source,ch:string):tstrings;function SplitString(const source,ch:string):tstrings;
var
temp:string;
i:integer;
begin
result:=tstringlist.Create;
temp:=source;
i:=pos(ch,source);
while i<>0 do
begin
result.Add(copy(temp,0,i-1));
delete(temp,1,i);
i:=pos(ch,temp);
end;
result.Add(temp);
end;============================
@* .☆ / */ . / * . ☆/ *。
◢◣。 ◢◣。
◢★◣。 ◢★◣。
◢■■◣。 ◢■■◣。
◢■■■◣。 ◢■■■◣。
︸︸||︸︸ !!︸︸||︸︸
愿您有快乐的每一天 ^_^!!
用SplitString(str,',')分割后再处理///分割一个字符串,其中分割的标志是ch
function SplitString(const source,ch:string):tstrings;function SplitString(const source,ch:string):tstrings;
var
temp:string;
i:integer;
begin
result:=tstringlist.Create;
temp:=source;
i:=pos(ch,source);
while i<>0 do
begin
result.Add(copy(temp,0,i-1));
delete(temp,1,i);
i:=pos(ch,temp);
end;
result.Add(temp);
end;============================
@* .☆ / */ . / * . ☆/ *。
◢◣。 ◢◣。
◢★◣。 ◢★◣。
◢■■◣。 ◢■■◣。
◢■■■◣。 ◢■■■◣。
︸︸||︸︸ !!︸︸||︸︸
愿您有快乐的每一天 ^_^!!
I: Integer;
T: string;
begin
with TStringList.Create do try
LoadFromFile('你的文件名');
Text := StringReplace(Text, #13#10#13#10, #13#10, [rfReplaceAll]); //去掉空行
///////Begin 合并两行
T := '';
for I := Count - 1 downto 0 do begin
if Odd(I) then begin
T := Strings[I];
Delete(I);
end else String[I] := String[I] + T;
end;
///////End 合并两行
///////Begin 处理格式
(*
000000000111111111122222222223333333333444444444455555555556
123456789012345678901234567890123456789012345678901234567890
- - - -
20020615 23:18:42,20020616 01:02:14,6212,02037355558
2002-06-15 23:18:42,2002-06-16 01:02:14,6212,02037355558
*)
for I := 0 to Count - 1 do begin
T := Strings[I];
Insert(T, '-', 25);
Insert(T, '-', 23);
Insert(T, '-', 07);
Insert(T, '-', 05);
Strings[I] := T;
end;
///////End 处理格式
SaveToFile('你的文件名');
finally
Free;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
f : TextFile;
S : TStringList;
J : Integer;
Str : String;
vS : String;
begin
try
S:=TStringList.Create;
S.LoadFromFile('rr.txt');
AssignFile(f,'rr.txt');
ReWrite(f);
J:=0;
Repeat
vS:=S.Strings[J];
Insert('-' , vS, 5);
Insert('-' , vS, 8);
Str:=vS+S.Strings[J+1];
Writeln(f,Str);
Inc(J,2);
Until J>S.Count-1;
CloseFile(f);
except
ShowMessage('出现异常!');
end;
ShowMessage('转换成功!');
end;
在Repeat……Until之间加 Insert('-' , vS, 25);
Insert('-' , vS, 28);
i, j: Integer;
s: TStringList;
begin
s := TStringList.Create;
if opendialog1.Execute then
s.LoadFromFile(opendialog1.FileName);
i := 0;
while i < s.Count do begin
if length(trim(s[i]))= 0 then
s.delete(i)
else if pos(',',s[i])= 0 then begin
j:=pos(',',s[i-1]);
s[i-1]:=copy(s[i-1],1,j)+copy(s[i-1],j+1,4)+'-'+copy(s[i-1],j+5,2)+'-'+copy(s[i-1],j+7,length(s[i-1])-j-6);
s[i-1]:=copy(s[i-1],1,j)+copy(s[i-1],j+1,24)+'-'+copy(s[i-1],j+25,2)+'-'+copy(s[i-1],j+27,length(s[i-1])-j-26);
s[i-1]:=s[i-1]+trim(s[i]);
s.delete(i);
end
else
inc(i);
end;
if savedialog1.Execute then
memo1.lines.SaveToFile(savedialog1.FileName);
end;