J3/05-108 To: J3 From: Dan Nagle Subject: Write CSV files Date: 2005 Jan 03 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. 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 format. Rationale: 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 LD. 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: Add a mode to the OPEN and/or WRITE statement, say, CSV="YES"|"NO". When CSV is present with a value of YES, LDIO output will use the comma as the value separator. When CSV is absent or present with a value of NO, the output separator is processor- dependent (the current case). Whether the processor will be premitted to write the r*value form is TBD. Optionally, the CSV mode could indicate the character, perhaps other than comma, to be used between values. Again, there must be exactly one such character between each pair of values. If the separator is allowed to be other than blank or comma, LDIO input is also affected. For completeness, one would like a specifier on the INQUIRE statement to detect when the CSV mode is in effect, but in the interests of simplicity, this paper does not propose to do so. History: M171 Paper J3/05-108