J3/05-108r1 To: J3 From: Dan Nagle Subject: Write CSV files Date: 2005 Feb 07 Fortran programs can read CSV files via list-directed I/O, but there's no easy way to write one since the separator between values is optionally blank or comma (with slash as a Really Special Case). Also, there's no guarantee there will be exactly one separator between each pair of values. If Fortran programs could easily write CSV files, the value of using Fortran programs along side spreadsheets etc would be higher than at present. Number: Title: Write CSV files Using LDIO Submitted By: J3 Status: For Consideration References: 04-007 10.9 Basic Functionality: Provide a quick and easy way to write files using the CSV (Comma Separated Value) format. Rationale: CSV files (a/k/a Comma Separated Value) files are used by spreadsheets and "higher level math" programs such as Mathematica, MATLAB and Maple. These programs provide easy access to graphics and other mathematically oriented amenities. List directed input treats the comma as a separator, but the separator is optionally blank or comma on output. If the separator is blank, one or more blanks may be between values. A way to make the optional separator a comma allows an easy way to write CSV files, providing easy communications to spreadsheet programs and other higher level math programs with built-in graphics, algebraic manipulation, and other amenities useful with numeric programs, but absent in standard Fortran. CSV files are formatted, the simplest format from the user's perspective is List Directed. So modify LDIO to serve CSV. Estimated Impact: Rather minor, the RTL must already reckon where to place a separator in LDIO output, and must already recognize comma on LDIO input. Detailed Specification: The idea is to modify list directed output as little as possible to gain connectivity from Fortran programs to desktop applications via CSV format. The proposed solution is: Add a new ACCESS form, ACCESS='CSV' which on output (and has no effect on input) 1. Implies ACCESS='STREAM', and 2. When list directed, requires that the processor not print the "r*" form of repeated values, and 3. When listed directed, disallows blanks as separator (which means comma or semicolon is used as per decimal mode), and 4. When listed directed, allows blanks on either side of the separator as at present, and 5. When listed directed, disallows new records being created (so one write gives one record), and 6. Allows explicit formats to be used as needed. History: M171 Paper J3/05-108