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



Be sure you have some process in place to be sure the csv file is what you want to process. We do this a lot and users like to do things like process the same file twice, add a column to the front of the csv not knowing that is going to mess things up, rename the csv file to something they like not what you need, open the csv in excel and save it after excel has decided to change columns, some have even changed the csv into an xls file and thought that would be ok.

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx [mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Raul A. Jager W.
Sent: Tuesday, February 05, 2013 6:47 AM
To: Midrange Systems Technical Discussion
Subject: Re: Looking for Ideas For Processing CSV

Read the file (IFS) directly in your RPG program. Use a RPG array to avoid reading twice, or simply do your validation and if passes, read again to update your database.
_______________________________________________________________________________
Michael Schutte wrote:

I have a request to process a CSV file and import the data into a file.

The first record will have column header with the name of the field
that it's suppose to update.

For example if in file ITEM_MASTER there are fields ITEM and DESCRIPTION


R ITEMMST
ITEM 20
DESCRIPTION 50


The CSV would look like this.

"ITEM","DESCRIPTION"
"1234","ITEM NUMBER 1"

The user would like to first see if there is an item that currently
exists and then update when found or write a new record.

So I got to thinking(bad idea), maybe I could somehow take the entire
csv record and put them into an array, easily... For example with a
SQL procedure or function you could


SET fields = ARRAY["ITEM", "DESCRIPTION"];
SET data = ARRAY["1234","ITEM NUMBER 1"];


Then I could loop through the array, do validation... when passed then
update item master file.

What do you think? Is there a better method when the number of columns
in the import file could differ?

If you like this idea, I'm having trouble finding examples of using SQL
Arrrays in RPGLE.


P.S. There will a ton a validation and put into a holding file prior
to updating the ITEM master.



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

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.