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



In Unix-type stream files, the general case is LF and no CRLF.

I would write an RPG module or program that uses the IFS APIs for stream
files, like open() in binary mode.
Then I would start read()ing the file one byte at a time and test each byte
for a hex 0D. If you find one, then read() the very next byte and test it
for a hex 0A.
I would stop just right there and assume that the whole file is delimited
by CRLF's.

If you find one hex 0A first, just keep read()ing until you find a second
hex 0A. I'd stop right there and assume the whole file is delimited only
by LF.

This is because it is not customary that a .csv has both delimiters.

HTH.

JS

El jue, 14 dic 2023 a las 13:30, Jack Woehr via MIDRANGE-L (<
midrange-l@xxxxxxxxxxxxxxxxxx>) escribió:

#!/QOpenSys/pkgs/bin/bash
TARGET_FILE=$1
/QOpenSys/pkgs/bin/grep $'\n' $TARGET_FILE >/dev/null
if [ "$?" == 0 ] ; then echo "contains lf"; else echo "contains no lf"; fi
/QOpenSys/pkgs/bin/grep $'\r' $TARGET_FILE >/dev/null
if [ "$?" == 0 ] ; then echo "contains cr"; else echo "contains no cr"; fi

On Thu, Dec 14, 2023 at 10:59 AM mlazarus <mlazarus@xxxxxxxxxxxx> wrote:

I'm looking for an easy way to determine if a .csv file in the IFS is
*CRLF vs. *LF programatically. The record delimiters will be consistent
throughout the file. So, if I want to copy it to a PF via CPYFRMIMPF, I
want the delimiter type returned to the program. TIA.

-mark



--

*JACK WOEHR, IBM Champion 2021-2023
<https://www.credly.com/users/jack-woehr/badges>*

*SENIOR IBM i ENGINEER*

303.847.8442
jwoehr@xxxxxxxxxxxxxxxxxxxxxxxx
<https://www.linkedin.com/in/jackwoehr/> stay connected
<https://www.linkedin.com/company/absolute-performance-inc./>

<https://www.absolute-performance.com/>
www.absolute-performance.com

NON-DISCLOSURE NOTICE: This communication including any and all
attachments is for the intended recipient(s) only and may contain

confidential and privileged information. If you are not the intended
recipient of this communication, any disclosure, copying further

distribution or use of this communication is prohibited. If you received
this communication in error, please contact the sender and

delete/destroy all copies of this communication immediately.
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.

Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.