Thanks for everyones help.
what I ended up doing was reading the stream and removing any #10
characters (LF). The I saved and reopened the file and added LF
after any instance of CR.
File is clean now.
Thanks again for everyones help.
In delphi-en (AT) yahoogroups (DOT) com, "Chris @ IT" <chris@iwrote:
Good point!
Cheers!
Chris Albert,
Innovative Technologies.
http://www.it.co.ke/beta
Message
From: delphi-en (AT) yahoogroups (DOT) com [mailto:delphi-en (AT) yahoogroups (DOT) com]
Behalf
Dave Sellers
Sent: Wednesday, August 10, 2005 9:44 PM
To: delphi-en (AT) yahoogroups (DOT) com
Subject: Re: [delphi-en] Re: CSV File export character problem
But don't look at i+1 when i = length(Buf1.Datastring) or it'll
fall
over for sure
Chris @ IT wrote:
>True look for any #10 in the string with no #13 following or the
other way
>round take your hex editor and get the exact order so that you
can get
>the following statement right
>
>If not (Buf1.Datastring[i] = #10 and Buf1.Datastring[i+1]<>#13)
>
or something
>
>Chris Albert,
>Innovative Technologies.
>http://www.it.co.ke/beta
Message
>From: delphi-en (AT) yahoogroups (DOT) com [mailto:delphi-
en (AT) yahoogroups (DOT) com]
Behalf
Dave Sellers
>Sent: Wednesday, August 10, 2005 9:30 PM
>To: delphi-en (AT) yahoogroups (DOT) com
>Subject: Re: [delphi-en] Re: CSV File export character problem
>
>Then work down your string considering two characters at a time
and copy
>into your other buffer accordingly. Chris has given you the
code, it
>only needs tweeking slightly.
>
>Trevor wrote:
>
>
>It appears that I have these LF characters that randomly
appear
>>in the middle of some lines. I want to strip these line feeds
out
>>(the ones that are in the middle of the lines).
>>
>>Thanks
>>
>In delphi-en (AT) yahoogroups (DOT) com, "Chris @ IT" <chris@i
wrote:
>
>>
>
>>
Same here I don't think we'll get what you really want;
What is it you want? Because stripping the LF from the end of
>>lines wount
>
>>
>
>>
really give you the results you are looking for
Chris Albert,
Innovative Technologies.
http://www.it.co.ke/beta
Message
From: delphi-en (AT) yahoogroups (DOT) com [mailto:delphi-
en (AT) yahoogroups (DOT) com]
>Behalf
>
>>
>
>>
Dave Sellers
Sent: Wednesday, August 10, 2005 9:11 PM
To: delphi-en (AT) yahoogroups (DOT) com
Subject: Re: [delphi-en] Re: CSV File export character problem
0A is Decimal 10: an LF.
At the end of your lines you will have a pair of characters
either
>>CR/LF
>
>>
>
>>
or LF/CR (I can't remember which way round) so as I said before
>>you need
>
>>
>
>>
to adapt the code to only strip out the LFs if immediately
>>followed (or
>
>>
>
>>
preceded by) a CR. If you take out all the LFs regardless your
>>end of
>
>>
>
>>
line pairs will become just CRs which you may get away with but
I
>>doubt
>
>>
>
>>
is what you're really after
Trevor wrote:
K. I got a hex editor and opened the file. It is showing the
character as hex 0A
BUt if I change the line to
If Buf1.Datastring[i] <#0A then
Buf2:=Buf2+Buf1.Datastring[i];
It does not compile.
Thanks again
In delphi-en (AT) yahoogroups (DOT) com, Dave Sellers
<davesellers@n
wrote:
Further to my last post - if that doesn't fix it, examine the
>>file
>
>>
>
>>
using
a hex editor and find out what it really is you're trying to
filter
out. Relying on Notepad's interpretation is probably not
wise
(IM)
Dave
Trevor wrote:
These strage characters are "CR" characters and show up as
>>little
>
>>
>
>>
square boxes if put into a TMemo.
I have tested the routine below and it works if I put one of
>>the
>
>>
>
>>
lines that has a one of these CR characters by iteself.
I therfore need to know how to stream in one line at a time
and
stram it back out to a new file after passing it through the
"If not (Buf1.Datastring[i] in [#13,#10]) then"
routine
Thaks
In delphi-en (AT) yahoogroups (DOT) com, "Chris @ IT" <chris@i
>>wrote:
>
>>
>
>>
You need to find out what these strange characters are;
then
>>put
>
>>
>
>>
them in the
"in [xxx]" clause of the code - then it will take them out.
Chris Albert,
Innovative Technologies.
http://www.it.co.ke/beta
Message
From: delphi-en (AT) yahoogroups (DOT) com [mailto:delphi-
en (AT) yahoogroups (DOT) com]
Behalf
Trevor
Sent: Wednesday, August 10, 2005 7:20 PM
To: delphi-en (AT) yahoogroups (DOT) com
Subject: [delphi-en] Re: CSV File export character problem
I need the lines to remain as lines. I only want the
strange
Characters removed from the start of the line to the end;
Thanks
In delphi-en (AT) yahoogroups (DOT) com, "Chris @ IT" <chris@i
wrote:
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);
:=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);
CopyFrom(Buf1,0);
Buf1.Free;
Free;
End;
Ive just typed this directly in outlook; might have some
bugs!
Chris Albert,
Innovative Technologies.
http://www.it.co.ke/beta
Message
From: delphi-en (AT) yahoogroups (DOT) com [mailto:delphi-
en (AT) yahoogroups (DOT) com]
Behalf
Trevor
Sent: Wednesday, August 10, 2005 6:45 PM
To: delphi-en (AT) yahoogroups (DOT) com
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:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
Home page:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
Home page:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
Home page:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
Home page:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
>>
>>
>>
>>
>>Home page:
>>To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
>>Yahoo! Groups Links
>>
>>
>>
>>
>>
>>
>>
>>
>
>>
>
>>
>
>
>
>
>
>Home page:
>To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
>
>
>Home page:
>To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
>Yahoo! Groups Links
>
>
>
>
>
>
>
>
Home page:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
Yahoo! Groups Sponsor
<font face=arial size=-1><a href="*
">Fair play? Video games influencing politics. Click and talk back!</a>.</font>
Home page:
To unsubscribe: delphi-en-unsubscribe (AT) yahoogroups (DOT) com
Yahoo! Groups Links
<*To visit your group on the web, go to:
<*To unsubscribe from this group, send an email to:
delphi-en-unsubscribe (AT) yahoogroups (DOT) com
<*Your use of Yahoo! Groups is subject to: