mmetc
Topics covered in this chapter:
This compatibility module just defines the diskdata procedure required to use data files formatted for mp-model from Mosel and provides a commercial discounting function. To use this module, the following line must be included in the header of the Mosel model file:
uses 'mmetc'
Procedures and functions
Annual discount.
|
|
Read in or write an array or set of strings to a file.
|
I/O drivers
This module provides the diskdata IO driver designed to be used as an interface for initializations blocks for both reading and writing files formated for the diskdata procedure.
Driver diskdata
diskdata:[dense|sparse|autondx|dataframe;][sglq|noq|csv|typedcsv;][cols();] [skiph;emptyndx;append;trans;nozeros;fsep=c;dsep=c]
The driver can only be used in `initializations' blocks. In the opening part of the block, no file name has to be provided, but general options can be stated at this point: they will be applied to all labels. In the block, each label entry is understood as the file name to use for the actual processing. Note that, before the file name, one can add further options separated by comas or semicolons, that are effective to the particular entry. Here, the csv and typedcsv options might be followed by a list of columns separated by commas and enclosed in parenthesis. This selection may also be achieved using the cols option. The columns are identified by their number (first column has index 1) and must be given in ascending order without duplicate. If the last column number is suffixed by the plus sign, the following columns will also be included in the selection (e.g. "csv(1,3+)" skips the second column). To use names, the option skiph must be used and the column names are taken from the header row that is skipped through this option. When using skiph, column numbers need to be stated by prefixing the column number by # (even in this case columns must be given in ascending order).This column selection is ignored for a writing operation. The file name given can use extended notation.
The diskdata driver takes the following options:
- dense
- dense data format
- sparse
- sparse data format
- autondx
- sparse data format with automatic indexation (applies only to 1-dimension arrays indiced by ranges)
- autondx=st
- same as autondx but starting index is set to st (instead of 1)
- dataframe
- dense data format for a 2-dimension array and first index as a range (for the line numbers)
- sglq
- strings quoted with single quotes
- noq
- strings are not quoted in the file
- csv
- use CSV format: quoting and escaping with double quotes, all lines are processed ( i.e. characters '!' and '&' are ordinary symbols), all columns are interpreted as text
- typedcsv
- same conventions as csv above except that unquoted strings are interpreted as integers, reals or booleans when reading (this impacts how unions are initialised)
- cols(c1[,c2,...])
- select a list of columns
- skiph
- When reading, the first line of the file is skipped, when writing, the first line of the file is preserved (or a comment line is inserted if the file does not already exist)
- emptyndx
- When reading array indices an empty cell causes a failure. With this option empty cells are replaced by the default value of the corresponding type ( e.g. 0 for a numerical value)
- append
- append output to the end of an existing file
- trans
- tables are transposed
- nozeros
- skip zero values when processing several arrays at the same time
- fsep=c
- character used to separate fields. The default value is ","; tabulation or ";" are also often employed
- dsep=c
- character used as decimal separator (default: ".")
Example:
declarations Set1: set of string ! Declare a set of strings ar1,ar2: array(Set1,range) of real ! Declare two dynamic arrays r: real ! Declare a real value end-declarations initializations from "diskdata:" ! Use 'diskdata' format for reading ar1 as "sparse;csv(1,3,4);ind.dat" ! Read `ar1' from 'in.dat' in sparse format ! using CSV conventions and selecting columns 1,3 and 4 r as "r_init.dat" ! Initialize `r' from 'r_init.dat' end-initializations initializations to "diskdata:append" ! Use 'diskdata' format for output [ar1, ar2] as "out.dat" ! Save two arrays in sparse format Set1 as "out.dat" ! Save set `Set1' to the same file end-initializations
© 2001-2025 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.