Chapter 6. Additional Text Formats

Table of Contents
6.1. Comma Separated Values (CSV) Format
6.2. Example of creating a CSV file
6.3. HTML (web page) format
6.4. Example of creating an HTML file

6.1. Comma Separated Values (CSV) Format

One type of text file that's commonly used is called "Comma Separated Values" (CSV) format. In CSV, you create a file, where each "record" in the file is a line of text, each line is broken up into "fields", and each field is separated by a comma.

CSV is useful for taking data from an OS/400 physical file and importing it into another program. Perhaps the most popular program is Microsoft Excel, but there are many others that will accept CSV as an input.

The OS/400 command called CPYTOIMPF can be used to create a stream file in CSV format without us having to write any code to do it. So, why are we doing this? One reason is that it helps you understand a little more about stream files. Another reason is that sometimes a little detail comes up that CPYTOIMPF does not support, and when that happens it's nice to have an alternative. Finally, there are times when your CSV file needs to contain data that requires program logic to generate.