Scott Klement's Working With CSV Data in RPG

Use this board for starting discussions, asking questions, and giving advice on RPG programming for the IBM i platform (and predecessors.)
csvrpg
New User
Posts: 7
Joined: Wed Jun 16, 2021 2:47 pm
First Name: cheryl
Last Name: carpenter
Company Name: K&M Associates
Phone: 4017842427
Address 1: 425 Dexter Street
City: Providence
State / Province: Rhode Island
Zip / Postal Code: 02907
Country: United States
Contact:

Re: Scott Klement's Working With CSV Data in RPG

Post by csvrpg »

2 more attachments to go with my saga.
Attachments
INVENTORYOUT scott1 080321.CSV
(54.71 KiB) Downloaded 1181 times
scott2 080321.jpg
scott2 080321.jpg (29.34 KiB) Viewed 19386 times
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Scott Klement's Working With CSV Data in RPG

Post by Scott Klement »

Sorry, I don't understand the question.

The first screenshot you posted today is SUPER tiny and hard to read... Can you tell me what the error message says? The second screenshot says something like "Line number 9: price: Must be a number" (and various other things after that). Well, what is in the price column on line 9?
Scott Klement
Experienced User
Posts: 2711
Joined: Wed Aug 01, 2012 8:58 am
First Name: Scott
Last Name: Klement
Company Name: Profound Logic
City: Milwaukee
State / Province: Wisconsin

Re: Scott Klement's Working With CSV Data in RPG

Post by Scott Klement »

Looking at your original inventoryBefore.csv file, the 'description' column has double quotes surrounding it. You are losing those in this case because you are using STRDLM(*NONE) on the CPYTOIMPF command. This means that when there is a comma in the data it will throw everything off.

Will they accept the file with STRDLM(*DBLQUOTE)?

inventoryBefore.csv has quotes around just that one column -- but not around all of the character columns. If you use STRDLM(*DBLQUOTE) it'll put quotes around all of them. So, you'd need to ask if that would be problematic for whomever is processing this file.

The alternative might be to manually put quotes around columns that contain a comma in the RPG code... but this seems like a PITA to do. It'd be much nicer if the format was consistent.
Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests