Avatar of Duke_W
Duke_W
 asked on

Upload CSV File to iSeries

I need to upload a CSV file to the iSeries. I have created a program withh DDS specs that define data field A as 15 bytes long. With a CSV file data field A in the first run may be 15 bytes long. The second run the file data field A may be only 5 bytes long. Is there a way to upload the CSV file as long as the columns are consistent? There is always a data field A in same spot it just has varing field lengths.
Operating SystemsSystem UtilitiesIBM System i

Avatar of undefined
Last Comment
Gary Patterson, CISSP

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Gary Patterson, CISSP

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Duke_W

ASKER
Can you expand on your answer a little bit. Like thenecessary steps to upload the file or do you put it in a folder? Once inb a folder then use the CPYTOIMPF command, etc.
SOLUTION
Member_2_276102

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Duke_W

ASKER
Hi Tom,

Can you please provide more details. Thanks
Gary Patterson, CISSP

  1. Open Navigator
  2. Nanvigate to the Integrated File System root (My Connections - you system - File Systems - Integrated File System - Root)
  3. Drag and drop your CSV there  (let's call it myfile.csv)
  4. Use the CPYTOIMPF command to copy the CSV (path is '/myfile.csv) into your database file.  Prompt the command read the extensive online help for each parameter. If you aren't familiar with AS/400 commands, type the command name on the command line of an interactive session and press F to prompt the command.  If you need help, put your cursor on the item that you want help with, and press F1.
The example below converts a CSV called "myfile.csv, located in the root of the AS/400 IFS to a dds or sql-described physical file called MYPHYISCAL in library MYLIB, replacing any datat that might already be in that file.  

The CSV has the following characteristics:

1) Each record ends with a carriage return and line feed (Windows-style)
2) The file is delimited
3) The field delimiter is a comma
4) The string delimiter is the doublequote character.

- Gary Patterson

CPYFRMIMPF FROMSTMF('/myfile.csv')  
           TOFILE(MYLIB/MYPHYSICAL) 
           MBROPT(*REPLACE)         
           RCDDLM(*CRLF)            
           DTAFMT(*DLM)             
           STRDLM(*DBLQUOTE)        
           FLDDLM(',')

Open in new window

Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
Member_2_276102

...press F to prompt the command...

Minor typo -- "press <F4> to prompt".

But pay attention to Gary. He has the knowledge and the time to provide as much as you need. It's rare that I even see significant typos in his answers.

Tom
Gary Patterson, CISSP

Tom,

Good catch.  Thanks!

- Gary