Import CSV file into PF in IBM i (AS400)

Import CSV file into PF in IBM i (AS400)
Import CSV file into PF in IBM i, CPYFRMIMPF, CPYTOIMPF,  Comma Separated Values (CSV), CPYTOIMPF , database file member, save file, Input/output (I/O) operations, source member, stream file, Current Working Directory, Stream file,ibmi,as400,iseries,systemi, working with ifs,as400 and sql tricks, as400 tutorial, ibmi tutorial, working with ifs, working with integrated file system, CPYTOIMPF in as400, copy to import file in ibmi, copy to import file in as400, copy pf to source member using cpytoimpf in ibmi as400, copy PF to flat file using cpytoimpf in ibmi as400, copy pf to stream file in ifs using cpytoimpf in ibmi as400,Generating CSV file in IFS using CPYTOIMPF command in IBM i(AS400),Generating CSV file in IFS using CPYTOIMPF command in AS400,iseries,systemi, comma separated values files,csv file in as400, csv in ibmi,comma separated values file in ibmi, comma separated values file in as400,Copy to Import File,comma-delimited stream file,
Import CSV file into PF in IBM i 

Easy way to import CSV file into PF

The CPYFRMIMPF is the command to copy this CSV file to the PF.

  • First we'll use the IFS stream file(CSV) we created using CPYTOIMPF command.
  • /home/EASYCLASS/TODAY.csv 

    Work with Links to browse IFS stream file.

    WRKLNK
                                 Work with Object Links                            
                                                                                   
     Directory  . . . . :   /home/EASYCLASS                                        
                                                                                   
     Type options, press Enter.                                                    
       2=Edit   3=Copy   4=Remove   5=Display   7=Rename   8=Display attributes    
       11=Change current directory ...                                             
                                                                                   
     Opt   Object link            Type             Attribute    Text               
           PF20                   STMF                                             
           SAVF1                  STMF                                             
           TODAY.CSV              STMF                                             
           UCSfile                STMF                                             
           UCSfile2               STMF                                             
           UCSfile4               STMF                                             
    
     Browse : /home/EASYCLASS/TODAY.CSV                                                      
     Record :       1   of       3 by  18                      Column :    1     97 by 131   
     Control :                                                                               
                                                                                             
    ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....
     ************Beginning of data**************                                             
    4   ,NAME4               ,ADDRESS4            ,"PART2                                    
    4   ,NAME4               ,ADDRESS4            ,"PART2                                    
    4   ,NAME4               ,ADDRESS4            ,"PART2                                    
     ************End of Data******************** 
  • Execute the following CPYFRMIMPF command to copy the CSV file to Physical File 'PF20'
  •                        Copy From Import File (CPYFRMIMPF)                     
                                                                                  
     Type choices, press Enter.                                                   
                                                                                  
     From stream file . . . . . . . . FROMSTMF     > '/home/EASYCLASS/TODAY.CSV'  
                                                                                  
     From file:                       FROMFILE                                    
       File . . . . . . . . . . . . .                                             
         Library  . . . . . . . . . .                  *LIBL                      
       Member . . . . . . . . . . . .                *FIRST                       
     To data base file:               TOFILE                                      
       File . . . . . . . . . . . . .              > PF20                        
         Library  . . . . . . . . . .              >   EASYCLASS1                 
       Member . . . . . . . . . . . .                *FIRST                       
     Replace or add records . . . . . MBROPT         *ADD                         
     Stream file record length  . . . STMFLEN        *TOFILE                      
     To CCSID . . . . . . . . . . . . TOCCSID        *FILE                        
     Record delimiter . . . . . . . . RCDDLM       > *LFCR                        
     Record format of import file . . DTAFMT         *DLM                         
     String delimiter . . . . . . . . STRDLM         *NONE
    

    This takes the data in the CSV file and inserts it into the physical file 'PF20'

     Selection or command                                                          
     ===>                                                                          
                                                                                   
     F3=Exit   F4=Prompt   F9=Retrieve   F12=Cancel   F13=Information Assistant    
     F23=Set initial menu                                                          
     3 records copied to member PF20.                                              
    
    RUNQRY *N PF20
                                                              Display Report                                                          
                                                                                                      Report width . . . . . :     100
     Position to line  . . . . .                                                                  Shift to column  . . . . . .        
     Line   ....+....1....+....2....+....3....+....4....+....5....+....6....+....7....+....8....+....9....+...10                      
            IDN   NAME                  ADDR1                 ADDR2                                                                   
     000001   4   NAME4                 ADDRESS4              "PART2                                                                  
     000002   4   NAME4                 ADDRESS4              "PART2                                                                  
     000003   4   NAME4                 ADDRESS4              "PART2                                                                  
     ****** ********  End of report  ********

    Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain