× 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.



The assumption here is that a field will contain 2 contiguous double quotes
What happens if the field contains one - or even worse - a number of non-contiguous double quotes

I hate using comma, single quote or double quote as a delimiter - much rather use tab - but even THAT is not guaranteed to be with no problems


Alan Shore
E-mail : ASHORE@xxxxxxxx
Phone [O] : (631) 200-5019
Phone [C] : (631) 880-8640
'If you're going through hell, keep going.'
Winston Churchill


-----Original Message-----
From: RPG400-L [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On Behalf Of John Yeung
Sent: Wednesday, August 30, 2017 11:27 AM
To: RPG programming on the IBM i (AS/400 and iSeries) <rpg400-l@xxxxxxxxxxxx>
Subject: Re: Parse a CSV format record with embedded double quote

On Wed, Aug 30, 2017 at 10:49 AM, Jeff Young <jyoung0950@xxxxxxxxx> wrote:
With the extra double quotes in the field, how can I determine the
correct position for the end of the field?

Well, honestly, I think the *best* way is to use a proper, prebuilt CSV parser. My favorite is of course the one that comes with Python.

But I believe the quickest way home in RPG is to first %SCANRPL all occurrences of adjacent double-quotes with some single replacement character that is guaranteed not to be in the data.

If you truly are just interested in the total length of the final data, you then just look for start and end quotes normally and get your number of bytes that way.

If you are reading in the data, then read in the modified string and do %SCANRPL at the end to replace the replacement character with double-quote.

This is of course assuming that CPYFRMIMPF doesn't properly handle embedded quotes. I don't remember off the top of my head if it does.

John Y.
--
This is the RPG programming on the IBM i (AS/400 and iSeries) (RPG400-L) mailing list To post a message email: RPG400-L@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at http://archive.midrange.com/rpg400-l.

Please contact support@xxxxxxxxxxxx for any subscription related questions.

Help support midrange.com by shopping at amazon.com with our affiliate link: http://amzn.to/2dEadiD


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.