MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » February 2013

RE: Looking for Ideas For Processing CSV



fixed

Another option might be to use the new Client Access transfer function from
the IBM i. See Craig Pelkie's article:
http://www.iprodeveloper-edition.com/iprodeveloper/201212?pg=4#pg9

Since you are looking for something new/neat.....


-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Michael Schutte
Sent: Monday, February 04, 2013 1:40 PM
To: Midrange Systems Technical Discussion
Subject: Re: Looking for Ideas For Processing CSV

Absolutely RPGLE is a possibility.

I thought about CPYFRMIMPF for record 1 only to get the header column into a
table.

Then another CPYFRMIMPF starting a record 2, to get the data into another
table.

There are currently 93 fields in the table. (not normalized, which really
irks me).

I suppose I'm really just being lazy today... looking for a neat/new
method... you know you like work more when you're learning to do something
new.

:-)


On Mon, Feb 4, 2013 at 4:31 PM, Alan Campin <alan0307d@xxxxxxxxx> wrote:

Why don't you just process the file directly in RPG and update the
file? I have wrapper service programs but no access to a machine at the
moment.
Search the archives for examples of using unix file api's. All kinds
of stuff out there.


On Mon, Feb 4, 2013 at 2:26 PM, Michael Schutte <mschutte369@xxxxxxxxx
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.


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


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







Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot 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 here. If you have questions about this, please contact