xRPG Core Library Additional Materials - CPYFTOCSV
The CPYFTOCSV command will allow you to create a stream file in .csv format. The command includes several options
that make it occassionally handier to CPYFRMIMPF:
- With CPYFTOCSV, you can choose whether or not to include the field names as the first row of the .CSV file. This
is especially handy if the file is to be read in by a 3rd party spreadsheet software. To include the header
row, set "Include Definition" to *YES (the default value).
- CPYFTOCSV includes three styles of delimiting:
- *ASCII - Standard ASCII delimiting: Double Quotes around character fields, no quotes around numeric fields.
- *QUOTE - Includes double quotes around every field.
- *NONE - No quotes are used.
- CPYFTOCSV allows you to include limited SQL support. You can specify a WHERE clause, an ORDER BY clause, and
the number of records to include in the file. WHERE and ORDER BY support is limited to the input field size of 100
characters.
- CPYFTOCSV has the option to automatically remove embedded commas from database fields. These can cause
many problems when transferring data to a spreadsheet. *YES is the default option.
There are a few caveats to remember when using CPYFTOCSV:
- The number of file fields the command can handle is limited to 255.
- The length of any given database field will be truncated to 128 characters.
- The command creates the stream file in the specified location and will overwrite an existing file with the
same name. If you do not specify a file name, the file will be created in the default location of
'/home/file.csv'. When you specify the file name, be sure to indicate the extension. Even though the
command is built for .csv files, it will NOT check to make sure you entered one!
- Currently there is no member support for CPYFTOCSV. If I can work through the kinks of using members with SQL I will update the command to allow members, but until that happens, if you need to copy a specific member, I would advise you to copy the member to its own file and then run CPYFTOCSV over that file.