Writesthe contents of one or more variables to a file in ASCII free format.
var_list The list of variables containing the values to be written. Note that variables of type structure are not supported. An exception to this is the !DT, or date/time, structure. It is possible to transfer date/time data using this routine.
Delim A single-character string that will be placed between values in the output data file. If you provide an array of strings, only the first string in the array will be used. If not provided, commas are used as delimiters in the file.
Dt_Template An array of integers indicating the data/time templates that are to be used for interpreting date/time data. Positive numbers refer to date templates; negative numbers refer to time templates. For more details, see Example 4. To see a complete list of date/time templates, see the PV-WAVE Programmer's Guide.
Miss_Str An array of strings that are substituted in the output file (to represent missing data) for each value in Miss_Vals. If not provided, no strings are substituted for missing data.
DC_WRITE_FREE relieves you of the task of composing a format string to describe the organization of the data in the output file. By default, DC_WRITE_FREE generates CSV (Comma Separated Values) files. However, you can override this default by using the Delim keyword to provide a different delimiter, if you wish.
NOTE: This function can be used to write data from date/time structures, but not from any other kind of structures.
NOTE: Any variable you include in var_list must have been previously created; otherwise, an error occurs.
As data is being transferred from multi-dimensional variables, those variables are treated as collections of scalar variables, meaning the first subscript of the export variable varies the fastest. For two-dimensional export variables, this implies that the column index varies faster than the row index. In other words, data transfer is row major; it occurs one row at a time. For more details about storing multi-dimensional variables in a column-oriented manner, see Writing Column-Oriented Data.
TIP: If an error does occur, view the contents of the file (using an operating system command) to see how much data was transferred. This will enable you to isolate the portion of the variable list in which the error occurred.
The various data types are stored using the default formats shown in the following table:
NOTE: When writing data of type string, each string is written to the file, flanked with a delimiter on each side. This implies that the strings should not contain delimiter characters if you intend to read the file later with the DC_READ_FREE function.
If you are interested in an illustration showing what row-oriented data can look like inside a file, see the PV-WAVE Programmer's Guide.
sara
is a floating-point array with 10 elements all equal to 1.0, tana
is a floating-point array with 5 elements all equal to 2.0, and cora
is a floating-point array with 8 elements all equal to 3.0, the function call:
status = DC_WRITE_FREE('outfile.dat', sara, tana, cora, /Row)
outfile.dat
containing the following values:
bogus
is a 4-by-4 integer array with values 1 through 4 in the first column, values 5 through 8 in the second column, values 9 through 12 in the third column, and values 13 through 16 in the fourth column, the following function call:
status = DC_WRITE_FREE('intfile.dat', bogus, Delim=[','], /Column)
intfile.dat
, as shown below:
1, 5, 9, 13 2, 6, 10, 14 3, 7, 11, 15 4, 8, 12, 16
bogus
.On the other hand, the function call:
status = DC_WRITE_FREE('intfile.dat', $ bogus(1,*), /Row, Delim='*')
intfile.dat
, as shown below:
5* 6* 7* 8
date
, time
, and phase_shift
. date
and time
are long integer vectors, and phase_shift
is a vector of complex (floating-point) values. The function call:
status = DC_WRITE_FREE('day539.dat', date, $ time, phase_shift, Delim='/', /Column)
day539.dat
that is organized as shown below:
921002/ 091200/( -0.139528, 0.983407) 921002/ 091205/( -0.149962, 0.407378) 921002/ 091210/( 1.002340, -0.039187) 921002/ 091215/( 1.130523, 0.983482) 921002/ 091220/( -0.947966, 0.171492) 921002/ 091225/( 1.275390, 0.789446)
float
and date
, that contain some data values and also some chronological information about when those data values were recorded:
date = [10/10/92 05:45:12, 11/11/92 10:10:51, 12/12/92 23:03:19] float = [1.2, 3.4, 5.6]
NOTE: The variable date is shown above as a series of strings, even though it is actually stored in a date/time structure as a series of integer and floating-point values.
date
is a date/time structure, and holds both date and time data. For more information on the internal structure of date/time structure variables, see the PV-WAVE Programmer's Guide. When you have date and time data stored in the same variable, the variable must be listed twice in the variable list in order to extract both the date and time data. The date/time templates that will be used to transfer this data have the following definitions:
Number | Template Description |
---|---|
1 | MM/DD/YY (/ = delimiter) |
-1 | HH:MM:SS (: = delimiter) |
status = DC_WRITE_FREE("thymus.dat", date, $ float, date, /Column, Dt_Template=[1,-1])
10/10/92 1.2 5:45:12 11/11/92 3.4 10:10:51 12/12/92 5.6 23:03:19
date
two different times. In each new output record, Template 1 is used first to write the date data from date. Next, a value from float
is written, and finally, Template -1 is used to write the time data from date
.
See the PV-WAVE Programmer's Guide for more information about free format I/O in PV-WAVE.