Back in 2008, I wrote a CSV utility (sometimes called "CSVR4") that could be used to read CSV files properly in an RPG program. You can read that article here (sorry, there isn't much formatting):
By popular demand I have put the code for this article here on my web site for people who would like to use it. The link is below:
UPDATE 2018-10-11: Added CSVINTO for DATA-INTO support. This requires IBM i 7.2+
UPDATE 2020-05-05: Added Unicode (UTF-16) support to CSVR4 via an additional parameter to CSV_open() and a new function CSV_getFldUni() see the prototypes in CSV_H and example in CSVDEMO4 for details.