× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I don't understand why everyone has a problem with CPYxxIMPF. I have
never had a problem after 5.4, which has been out for quite a while
now. The only problem I had prior was with escape characters.

Anyway, James your code is missing one key thing. You have to make
sure the double quote is not an escape character. Generally speaking
in a CSV when you have a string that contains a double quote, it is
escaped with another double quote.

It's not really a hard thing to write, it's just hard thing to get
right. There are just several variables you have to watch for. You
have to make sure any delimiters in the string are processed as part
of the string. I find it easier to just use CPYTOIMPF, it's all
already done for me.

--
James R. Perkins



On Tue, Feb 16, 2010 at 13:46, James H. H. Lampert
<jamesl@xxxxxxxxxxxxxxxxx> wrote:
Of course, it's not all that difficult to write a recursive descent
parser in ILE RPG. And in your case, it wouldn't actually need the
recursion.

Pseudocoded:

For each record
  Start with the cursor at the beginning of the record, and loop:
    IF the cursor is on a quote
      Advance the cursor one character position
      Find the first quote after the cursor position
      Field is between the cursor (incl) and the quote (excl)
      Advance the cursor to the closing quote
      Find the first comma or EOR after the cursor position
    ELSE (the cursor isn't on a quote)
      Find the first comma after the cursor position
      Field is between the cursor (incl) and the comma or EOR (excl)
    ENDIF
    IF we found a comma, instead of EOR
      Advance the cursor to one character position past that comma
      Continue the line loop
    ENDIF
Next record


And you can even use The Cycle as your record loop.

--
JHHL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.