Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
Reading CSV files in RPG
has no ratings.
Published: 02 Nov 2011
Revised: 20 Oct 2013 - 3694 days ago
Last viewed on: 30 Nov 2023 (7562 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

Reading CSV files in RPG Published by: Bob Cozzi on 02 Nov 2011 view comments(4)

RPG xTools has always had CSV Generation APIs, but now I've built a CSV reader API for RPG. Question is, is this something lots of people need?  I know I'm using CPYFRMIMPF all the time (coming from Excel) so the ability to read and parse the CSV file directly is very helpful to me. 

Any comments?

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS

(Sign in to Post a Comment)
Posted by: Viking
Premium member *
CA
Comment on: Reading CSV files in RPG
Posted: 12 years 27 days 6 hours 16 minutes ago

That would be useful.  Post it as your next RPG Report newsletter!

Posted by: bobcozzi
Site Admin ****
Chicagoland
Comment on: Reading CSV files in RPG
Posted: 12 years 27 days 4 hours 14 minutes ago

What I've got working is the parser itself.

RPG xTools has the "read IFS file" thing in it.

But right now, the parse accepts a "row" of data, parses it and returns the results to an array.

So each CSV value is stored in an individual array element which the programmer would then use EVAL along with %DEC or straight assignment to move the elements into the corresponding fields.

Like my Write To CSV API, I would probably include an API in xTools that provides an Open, read record, close thing.

Posted by: paul.raulerson
Premium member *
Comment on: Reading CSV files in RPG
Posted: 10 years 1 months 15 days 18 hours 46 minutes ago

Wish I had not lost track of you guys when the old system shut down, this post would have been very useful to me tonight.

 

I just had to spend a hour writing an import module for a CSV file. :)  It wasn't tough of course, not with %SUBST and %SCAN. And wasn't generic either, it was for one single format - but it amazes me how much I forget if I am not using it each day. ;)

-Paul

 

Posted by: clbirk
Premium member *
Comment on: Reading CSV files in RPG
Posted: 10 years 1 months 10 days 43 minutes ago

I recently watched a video of Jon Paris, talking about rpg open access which contrary to the opinion of some, it is more than just for web enablement. He did examples of using OA to write csv files and so reading is also something and unlike passing the results back in an array, etc. one could get them loaded right into the fields.

anyone using OA to do webservices, read/write csv files, etc.?