ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

CSV Garbage output to flat file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • CSV Garbage output to flat file

    Hi all,

    I have a CSV file located in my IFS. It has two fields that are separated by a TAB (I believe, I have little to no information on how this was exported).
    Here is the snippet from that file (depersonalized values):
    ACBKDTA
    Code:
    ACCID    BKID
    10000001    XX0000
    20000002    XX0000
    20000003    XX0100
    30000003    XX0200
    Command:
    Code:
    CPYFRMIMPF FROMSTMF('/home/ACBKDTA.csv') TOFILE(*LIBL/ACBKPF) MBROPT(*REPLACE)
        STRDLM(*NONE) FLDDLM(*TAB)
    Also ACBKDTA is a 'flat-file' created using the following command:
    Code:
    CRTPF FILE(ACBKPF) RCDLEN(1024)
    I have tried this command a few times and sometimes return "Error code 5" - What does this mean? When the command does complete successfully, I go to look at the data in the table and it contains unreadable text for all records - Why is this happening (is this a problem with CCSID, and if so what ID should I be using)?

    All help is greatly apprieciated!

  • #2
    Originally posted by Bull_A_ View Post
    I have tried this command a few times and sometimes return "Error code 5" - What does this mean? When the command does complete successfully, I go to look at the data in the table and it contains unreadable text for all records - Why is this happening (is this a problem with CCSID, and if so what ID should I be using)?
    Where do you see "Error code 5"? Without sufficient context, it's difficult to guess what happened. Possibly a joblog that shows a message (including message ID) could be most useful.

    And the CCSID guess seems reasonable, but it's hard for us to guess what you should use on your system. The default for CRTPF is CCSID(*JOB). Different jobs may use different job CCSIDs. And we have no idea how attributes for '/home/ACBKDTA.csv' were set nor what CCSID was used to write data into it. Details may make differences in advice.
    Tom

    There are only two hard things in Computer Science: cache invalidation, naming things and off-by-one errors.

    Why is it that all of the instruments seeking intelligent life in the universe are pointed away from Earth?

    Comment


    • #3
      If you want to use the CPYFRMIMPF command, then the target file should be defined with the proper number of fields in it (2 in your example). If you want to use the 'flat file', then switch to the CPYFRMSTMF command. If you create a real database file and use the CPYFRMIMPF command or use the CPYFRMSTMF command with the flat file, the character conversion issue should take care of itself assuming that the stream file has the correct CCSID.

      Comment

      Working...
      X