I actually worked through it fine.  If 10 programmers attempted this the
code would be written 10 different ways but below is what I use.  This
works fine if the csv file is a "windows" version where lines end in a
LF:CR.  I need to adapt this to work with files generated on other systems.

In my case I'm working with descriptions that end up as HTML so I convert
the embedded characters to a line break "<br>" sequence.  I use this to
get a full line and them dump that line through a parser that processes
the line.

- Josh

LINE.NUM = 0
            LINE = ''
            LAST.VAL = ''
            IN.QUOTES = @FALSE

            LOOP
            WHILE READBLK VAL FROM D.PATH,1 DO
               BEGIN CASE
                  CASE VAL = CHAR(13) AND NOT(IN.QUOTES)
                     GOSUB PROCESS.LINE
                     LINE = ''
                  CASE VAL = '"' AND IN.QUOTES
                     IN.QUOTES = @FALSE
                     LINE := VAL
                  CASE VAL = '"'
                     IN.QUOTES = @TRUE
                     LINE := VAL
                  CASE VAL = CHAR(13) AND IN.QUOTES
                     LINE := '<br>'
                  CASE VAL = CHAR(10) AND LAST.VAL = CHAR(13)
                  CASE VAL = CHAR(10)
                     LINE := '<br>'
                  CASE 1
                     LINE := VAL
               END CASE
               LAST.VAL = VAL
            REPEAT

            IF LINE # '' THEN
               GOSUB PROCESS.LINE
               LINE = ''
            END





On 2/9/12 11:55 AM, "Charlie Noah" <cwn...@comcast.net> wrote:

Hi Josh,

I'd be happy to share my routines with you, if they would be of any use.
I have a program I use to load a csv file, and a subroutine which
converts back and forth between csv, dynamic and fixed width, either a
line at a time or an entire flat file.

Charlie

On 02-09-2012 10:44 AM, Joshua Gallant wrote:
> I was going to ask the same question about embedded line feeds.  I've
>been
> dealing with a lot of outside companies the last few months transferring
> data and found a lot have embedded line feeds all over.
>
> - Josh
>
>
>
>
>
> On 2/9/12 11:11 AM, "George Gallen"<ggal...@wyanokegroup.com>  wrote:
>
> Is it possible that the URL has an embedded lf at the end from entry on
> the source side?
>
> I've created csv files comma/quoted that contained URLs and were quite
> long and didn't have any issues importing
>    Them into excel as a .csv , at least not as breaking into two lines.
>
> George
>
> -----Original Message-----
> From: u2-users-boun...@listserver.u2ug.org
> [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Charlie Noah
> Sent: Thursday, February 09, 2012 11:06 AM
> To: U2 Users List
> Subject: Re: [U2] Building an Excel File
>
> Thanks George. I changed the tabs to pipes just to display them here.
> Normally I save as tab delimited with no surrounding character. Since
> the cell contents copies and pastes as 2 lines, I'm not sure whether
> these suggestions would solve my problem.
>
> Thanks again,
> Charlie
>
> On 02-09-2012 8:54 AM, George Gallen wrote:
>> Not sure if this helps...
>>
>> I noticed that you were showing pipe delimited lines...
>> If you rename your file from .csv to .txt
>>
>> Then from excel, you use the "Open" option, and then you can set the
>> delimiter to |
>>      And also change the column types before it imports it, or have it
>> skip a column as well.
>>
>> George
>>
>> -----Original Message-----
>> From: u2-users-boun...@listserver.u2ug.org
>> [mailto:u2-users-boun...@listserver.u2ug.org] On Behalf Of Charlie Noah
>> Sent: Thursday, February 09, 2012 9:46 AM
>> To: U2 Users List
>> Subject: Re: [U2] Building an Excel File
>>
>> While everyone is thinking about CSV and Excel, maybe I can get a
>> solution to a problem that's been plaguing me for a long time.
>>
>> _______________________________________________
>> U2-Users mailing list
>> U2-Users@listserver.u2ug.org
>> http://listserver.u2ug.org/mailman/listinfo/u2-users
>>
> _______________________________________________
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
> _______________________________________________
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
> _______________________________________________
> U2-Users mailing list
> U2-Users@listserver.u2ug.org
> http://listserver.u2ug.org/mailman/listinfo/u2-users
>
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to