Unconfigured Ad Widget

Collapse

Announcement

Collapse
No announcement yet.

.CSV files

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

  • #16
    .CSV files

    It's MUCH easier to simply perform a CPYTOIMPF from your file to a flat file (the import file), then copy the import file to the document using the CPYTOPCD. The CPYTOIMPF will put double quotes (delimiters) around all text fields by default. Thus, your text fields containing numbers will be treated as text when you open it in Excel. To the users it's transparent and no one needs to mess with column formatting. CPYTOIMPF FROMFILE(WORKFILE) TOFILE(IMPORT) CPYTOPCD FROMFILE(IMPORT) TOFLR(WRKFLR) + TODOC(TEST.CSV) REPLACE(*YES) SNDDST TYPE(*DOC) TOINTNET((&EMAIL)) + DSTD('Test Document') + DOC(TEST.CSV) FLR(WRKFLR) The import TOFILE is simply a flat file that needs to be long enough to allow the length of the file, plus commas (CSV is comma separated value, after all) in between each field in the file, plus delimiters around each text field and a "fudge factor" of around 30% to allow for packed fields if you have them. If it's not long enough, the CPYTOIMPF will fail. One extra line in the CL and the problem is taken care of. Now, if I could only figure out how to get double quotes and commas that are in description fields (for inches or as quotes) to not cause any problems. I've always had to xlate them to something else so the CSV file opens correctly. That's another issue. Good luck.

    Comment


    • #17
      .CSV files

      I am using the CPYTOPCD command to copy a .CSV file to a folder, then emailing this in Excel format. When bringing this up in Excel, it is deleting the leading 0's (Zeros)from alpha fields. What do I need to do to correct this? Thank you

      Comment


      • #18
        .CSV files

        From http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm # Fields that contain double quote characters must be surounded by double-quotes, and the embedded double-quotes must each be represented by a pair of consecutive double quotes. So, John "Da Man" Doe would convert to "John ""Da Man""",Doe, 120 any st.,...

        Comment

        Working...
        X