Examples of common export calls are provided below.
It is convenient to set up one or more import directory paths up front. For example:
string $exportDir= $modelHome + "/exportData"
This code exports a 2-dimensional population TOOL object (by age, by time) to a csv file with age in the rows and time in the columns.
export (refPop[a,ts]; dataFormat=coordinate, fileFormat=text, allCoord=off, delimiter=",", \ heading=on, file=$exportDir/refPop.csv)
This format is useful for migrating data between models in a human-readable format, as opposed to binary tool-format files. Note the use of expForm
and decimals
parameters to preserve precision.
export (immigration[s,ts1,a]; dataFormat=odometer, fileFormat=text, \ expForm=on, decimals=6, \ file=$exportDir/immigration.txt)
produces the following (header not shown):
! sex=male ! 0 1 2 "1977" 1.049407e+02 1.314661e+02 1.317941e+02 "1978" 9.129648e+01 1.133035e+02 1.212180e+02 "1979" 8.643492e+01 9.573391e+01 9.366822e+01 "1980" 9.673356e+01 9.806976e+01 9.806976e+01
See the corresponding import call.
This is an example of exporting to whatIf's native (binary) TOOL file format:
export (customCensusPop[pzce,s,byrs,acc]; format=tool, file=$exportDir/customCensusPop)