Simplest best way always works!!
Use the procedure below: note that this will remove ALL CR/LF in file
Which might not be exactly what you want; you'll end up will all the data in
one row; if you are talking of CSV's
Procedure remove_cr_lf(infile,outfile : string);
Var
Inf,outf : tfilestream;
Buf1 : TStringStream;
Buf2 : string;
i : integer;
Begin
Inf:=tfilestream.create(infile,fmopenread);
Outf:=tfilestream.create(outfile,fmcreate);
Buf1:=TStringStream.Create('');
Buf1.CopyFrom(Inf,0);
Inf.Free;
Buf2:='';
For i:=1 to length(Buf1.Datastring) do
If not (Buf1.Datastring[i] in [#13,#10]) then
Buf2:=Buf2+Buf1.Datastring[i];
Buf1.Free;
Buf1:=TStringStream.Create(Buf2);
Outf.CopyFrom(Buf1,0);
Buf1.Free;
Outf.Free;
End;
Ive just typed this directly in outlook; might have some bugs!
Chris Albert,
Innovative Technologies.
http://www.it.co.ke/beta
-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
Of Trevor
Sent: Wednesday, August 10, 2005 6:45 PM
To: [email protected]
Subject: [delphi-en] CSV File export character problem
Need help in stripping out unwanted characters in a text file.
I exported a EXCEl spread sheet to a .csv file. I fI look at the file
in notepad all entries show up on individual lines. But on closer
inspection there are either "CR" or "LF" charcters on some lines.
Therfore when I open the file into oa TMemo component it seperates any
line that contains one of these characters into two lines.
I tried reding it into a stringlist and then writing the individual
lines to a TMemo but that produced the same result.
How can I remove these characters (ie CR & LF) charaters that are in
the middle of some of the lines.
Thanks
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor --------------------~-->
<font face=arial size=-1><a
href="http://us.ard.yahoo.com/SIG=12hgsq0s6/M=362335.6886445.7839731.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1123696658/A=2894361/R=0/SIG=13jmebhbo/*http://www.networkforgood.org/topics/education/digitaldivide/?source=YAHOO&cmpgn=GRP&RTP=http://groups.yahoo.com/">In
low income neighborhoods, 84% do not own computers. At Network for Good, help
bridge the Digital Divide!</a>.</font>
--------------------------------------------------------------------~->
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/