Link to home
Start Free TrialLog in
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.
ASKER CERTIFIED SOLUTION
Avatar of Gary Patterson, CISSP
Gary Patterson, CISSP
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Duke_W
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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Duke_W

ASKER

Hi Tom,

Can you please provide more details. Thanks
  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

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

Good catch.  Thanks!

- Gary