Original Message----- >From: Parag Kalra [mailto:paragka...@gmail.com] >Sent: Wednesday, January 05, 2011 16:42 >To: Wagner, David --- Senior Programmer Analyst --- CFS >Cc: Perl Beginners >Subject: Re: Getting LineFeed for Excel within q quoted field > >Ok. > >May be I need to understand your scenario in better way. Kindly >correct me if I am wrong. So this is what my understanding is: > >1. Your aim is to generate a CSV file >2. You are parsing a flat text file and substituting ^ with new line >character (0a) >3. But when you are viewing the file in Excel the new character is not >added [Wags] Not quite. I look at the file using Hex application. What I see in the file is 0d0a where I would expect to ONLY see 0a. As another test, I changed the 0a to 0f and Ran my script. When I look at the file, it ONLY has the 0f. So what I am thinking is That Perl sees the 0a and says he is not doing it right, so we will replace with a 0d0a since on Windows. Simplistic, but that is what I am seeing.
So how do I tell Perl to leave alone on 0a. Do I have to play with $? Or ??? Making no sense to me at this point... So what are the thoughts now??? If you have any questions and/or problems, please let me know. Thanks. Wags ;) David R. Wagner Senior Programmer Analyst FedEx Services 1.719.484.2097 Tel 1.719.484.2419 Fax 1.408.623.5963 Cell http://Fedex.com/us >4. And reason as per what you think is that Excel is expecting 0a but >what is getting inserted is 0d0a >5. Also I assume you are doing all these experiments on Windows box. >The reason I am asking this is because both Linux and Windows treat >new line character in different way. Have a look - >http://www.perlmonks.org/index.pl?node_id=68687 >And from the same reference it appears to me that if you want to add >only 0a, may be you need to handle the csv file in ascii format > >Cheers, >Parag > > > > >On Wed, Jan 5, 2011 at 3:28 PM, Wagner, David --- Senior Programmer >Analyst --- CFS <david.wag...@fedex.com> wrote: >> >>>-----Original Message----- >>>From: Parag Kalra [mailto:paragka...@gmail.com] >>>Sent: Wednesday, January 05, 2011 12:13 >>>To: Wagner, David --- Senior Programmer Analyst --- CFS >>>Cc: Perl Beginners >>>Subject: Re: Getting LineFeed for Excel within q quoted field >>> >>>It may have to do something how you are opening the file handler of CSV >>>file. >>> >>>The data you seen in the csv file may depend on which encoding you >>>have used while creating the file. >>> >>>Couple of questions: >>> >>>1. I believe currently you are view the file on Windoze, when you view >>>the file on Unix, do you still see the graphics. >> >> [Wags] I am viewing with Scite and also a Hex editor. >> But even when I am doing the change using s/\^/\x0a/g I am seeing in the >file itself as 0d0a and not just the 0a. Obviously I am missing something >very basic at this point. Excel is expecting a 0a indicating a soft return, >and I have verified I am using the right code, but comes out incorrectly. >> >> What am I missing?? >> >> Thanks much for any insight.. >> >> Wags ;) >> David R. Wagner >> Senior Programmer Analyst >> FedEx Services >> 1.719.484.2097 Tel >> 1.719.484.2419 Fax >> 1.408.623.5963 Cell >> http://Fedex.com/us >> >> >> >>>2. Is graphics visible on most of the editors or have you used only 1 >>>editor? >>> >>>Cheers, >>>Parag >>> >>> >>> >>> >>>On Tue, Jan 4, 2011 at 3:56 PM, Wagner, David --- Senior Programmer >>>Analyst --- CFS <david.wag...@fedex.com> wrote: >>>> I am generating an CSV and want a couple of fields to have soft >>>> returns in them. I went into Excel and added a couple of soft returns >to >>>> a couple of different fields and then saved the modified file back to a >>>> CSV. >>>> I opened in a editor and reviewed what was there. What I saw >>>> was: >>>> "xxxxxxxxxxx(lf) # shows as LF verses the std end of line for >>>> windows of CR/LF >>>> Yyyyyyyyyyyy(lf) >>>> " >>>> >>>> I left the editor and double clicked again and brought into >>>> Excel. The data had the soft returns. >>>> >>>> So I added the following to my processing: >>>> >>>> for ( @MyWorka ) { >>>> if ( /\^/ ) { >>>> s/\^/\x0a/g; # I have tried the \r and even >>>> \n and when opened in >>>> # Excel always has the >>>> graphic explained below.... >>>> } >>>> } >>>> >>>> Whereever there is a ^ replace with a hex A which to me is a >>>> LineFeed ( incorrectly as I have read ). I run and create my csv. I >>>> double click the file and it opens in Excel. It appears to be working, >>>> but where each linefeed is you get a little graphic with a question >mark >>>> inside a circle. In a way it is doing the soft returns, but obviously >>>> not correctly. >>>> >>>> Any thoughts on what I am doing incorrectly?? >>>> >>>> Thanks. >>>> >>>> Wags ;) >>>> David R. Wagner >>>> Senior Programmer Analyst >>>> FedEx Services >>>> 1.719.484.2097 Tel >>>> 1.719.484.2419 Fax >>>> 1.408.623.5963 Cell >>>> http://Fedex.com/us >>>> >>>> >>>> >>>> -- >>>> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >>>> For additional commands, e-mail: beginners-h...@perl.org >>>> http://learn.perl.org/ >>>> >>>> >>>> >>