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 [email protected], "Chris @ IT" <[EMAIL PROTECTED]> wrote: > Good point! > > Cheers! > > Chris Albert, > Innovative Technologies. > http://www.it.co.ke/beta > > > -----Original Message----- > From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf > Of Dave Sellers > Sent: Wednesday, August 10, 2005 9:44 PM > To: [email protected] > 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 > > > > > >-----Original Message----- > >From: [email protected] [mailto:delphi- [EMAIL PROTECTED] On > Behalf > >Of Dave Sellers > >Sent: Wednesday, August 10, 2005 9:30 PM > >To: [email protected] > >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: > > > > > > > >>Ok. 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 [email protected], "Chris @ IT" <[EMAIL PROTECTED]> 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 > >>> > >>> > >>>-----Original Message----- > >>>From: [email protected] [mailto:delphi- [EMAIL PROTECTED] > >>> > >>> > >>> > >>> > >>On Behalf > >> > >> > >> > >> > >>>Of Dave Sellers > >>>Sent: Wednesday, August 10, 2005 9:11 PM > >>>To: [email protected] > >>>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: > >>> > >>> > >>> > >>> > >>> > >>>>OK. 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 [email protected], Dave Sellers <[EMAIL PROTECTED]> > >>>>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 > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>> > >>>>(IMO) > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>>>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 [email protected], "Chris @ IT" <[EMAIL PROTECTED]> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>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 > >>>>>>> > >>>>>>> > >>>>>>>-----Original Message----- > >>>>>>>From: [email protected] [mailto:delphi- > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>[EMAIL PROTECTED] > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>On Behalf > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>>>Of Trevor > >>>>>>>Sent: Wednesday, August 10, 2005 7:20 PM > >>>>>>>To: [email protected] > >>>>>>>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 [email protected], "Chris @ IT" <[EMAIL PROTECTED]> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>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); > >>>>>>>>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:delphi- > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>[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 > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>> > >>>>>>>----------------------------------------------------- > >>>>>>>Home page: http://groups.yahoo.com/group/delphi-en/ > >>>>>>>To unsubscribe: [EMAIL PROTECTED] > >>>>>>>Yahoo! Groups Links > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>> > >>>>>>----------------------------------------------------- > >>>>>>Home page: http://groups.yahoo.com/group/delphi-en/ > >>>>>>To unsubscribe: [EMAIL PROTECTED] > >>>>>>Yahoo! Groups Links > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>>>> > >>>> > >>>>----------------------------------------------------- > >>>>Home page: http://groups.yahoo.com/group/delphi-en/ > >>>>To unsubscribe: [EMAIL PROTECTED] > >>>>Yahoo! Groups Links > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>> > >>>----------------------------------------------------- > >>>Home page: http://groups.yahoo.com/group/delphi-en/ > >>>To unsubscribe: [EMAIL PROTECTED] > >>>Yahoo! Groups Links > >>> > >>> > >>> > >>> > >> > >> > >> > >>----------------------------------------------------- > >>Home page: http://groups.yahoo.com/group/delphi-en/ > >>To unsubscribe: [EMAIL PROTECTED] > >>Yahoo! Groups Links > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > >> > > > > > > > > > >----------------------------------------------------- > >Home page: http://groups.yahoo.com/group/delphi-en/ > >To unsubscribe: [EMAIL PROTECTED] > >Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > >----------------------------------------------------- > >Home page: http://groups.yahoo.com/group/delphi-en/ > >To unsubscribe: [EMAIL PROTECTED] > >Yahoo! Groups Links > > > > > > > > > > > > > > > > > > > > > > > > > > > ----------------------------------------------------- > 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=12hne48tq/M=362329.6886308.7839368.1510227/D=groups/S=1705115362:TM/Y=YAHOO/EXP=1123718391/A=2894321/R=0/SIG=11dvsfulr/*http://youthnoise.com/page.php?page_id=1992 ">Fair play? Video games influencing politics. Click and talk back!</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/

