This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
howtos:workwithdata:import_quick_reference [2011/08/25 14:48] marcus.williams |
howtos:workwithdata:import_quick_reference [2017/05/18 14:51] (current) marcus.williams [advanced import examples] |
||
---|---|---|---|
Line 4: | Line 4: | ||
<code> | <code> | ||
- | string $importDir= $home + "/V1/primaryData" | + | string $importDir= $modelHome + "/V1/primaryData" |
</code> | </code> | ||
Line 14: | Line 14: | ||
===== csv file ===== | ===== csv file ===== | ||
+ | |||
+ | ==== basic import ==== | ||
This is an example of importing into a very simple mask variable, //zoneMask[z]//, indexed by a single pre-defined informant, //zone//. Here is the top of the source data file //zonesMask.csv//: | This is an example of importing into a very simple mask variable, //zoneMask[z]//, indexed by a single pre-defined informant, //zone//. Here is the top of the source data file //zonesMask.csv//: | ||
Line 49: | Line 51: | ||
file=$importDir/zonesMask.csv) | file=$importDir/zonesMask.csv) | ||
</code> | </code> | ||
+ | |||
+ | ==== advanced import examples ==== | ||
+ | |||
+ | <code> | ||
+ | local occPrivDwellCustSC_1[pzans,dtd] = create (; \ | ||
+ | dim=PLUMzoneAllNS, dim=dwellType_data, \ | ||
+ | entityFrom=occPrivDwellCustSC[pzans,dt,byrs][$index], \ | ||
+ | dataFormat=coordinate, fileFormat=text, \ | ||
+ | allCoord=off, delimiter=",", firstLine=2, \ | ||
+ | searchElemName1=",", replaceElemName1="", \ | ||
+ | searchElemName2="/", replaceElemName2="_", \ | ||
+ | searchElemName3="-", replaceElemName3="_", \ | ||
+ | replaceWhiteSpaceInElemName="_", \ | ||
+ | stripLeadingWhiteSpace=off, \ | ||
+ | searchData=",", replaceData="" , \ | ||
+ | file=$importDir/dwellUnitsByType.csv) | ||
+ | </code> | ||
+ | ==== read localinformants ==== | ||
+ | |||
+ | Read informant definition from column: | ||
+ | |||
+ | <code> | ||
+ | localinformant age_0510002[] = create (; object=set, delimiter=",", \ | ||
+ | allowDuplicate=on, \ | ||
+ | elemNamesFromColNum=3, firstLine=2, \ | ||
+ | searchElemName1=",", replaceElemName1="", \ | ||
+ | searchElemName2="/", replaceElemName2="_", \ | ||
+ | searchElemName3="-", replaceElemName3="_", \ | ||
+ | replaceWhiteSpaceInElemName="_", \ | ||
+ | stripLeadingWhiteSpace=off, \ | ||
+ | file=$importDir/051-0002.csv) | ||
+ | </code> | ||
+ | |||
+ | Read informant definition from line: | ||
+ | |||
+ | <code> | ||
+ | localinformant date_0510002[] = create (; object=set, delimiter=",", \ | ||
+ | allowDuplicate=off, \ | ||
+ | elemNamesFromLineNum=1, firstCol=4, \ | ||
+ | searchElemName1=",", replaceElemName1="", \ | ||
+ | searchElemName2="/", replaceElemName2="_", \ | ||
+ | searchElemName3="-", replaceElemName3="_", \ | ||
+ | replaceWhiteSpaceInElemName="_", \ | ||
+ | stripLeadingWhiteSpace=off, \ | ||
+ | file=$importDir/051-0002.csv) | ||
+ | </code> | ||
+ | |||
===== tab delimited text odometer (block) format ===== | ===== tab delimited text odometer (block) format ===== | ||
- | 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. | + | This format is useful for migrating data between models in a human-readable format, as opposed to binary //tool//-format files. |
<code> | <code> | ||
- | export (immigration[s,ts1,a]; dataFormat=odometer, fileFormat=text, \ | + | immigration[s,ts1,a][$index] = import (; dataFormat=odometer, fileFormat=text, \ |
- | expForm=on, decimals=6, \ | + | firstCol=2, file=$importDir_V3/immigration.txt) |
- | file=$exportDir/immigration.txt) | + | |
</code> | </code> | ||
- | produces the following (header not shown): | + | reads from the following (header not shown): |
<file> | <file> | ||
Line 69: | Line 117: | ||
"1980" 9.673356e+01 9.806976e+01 9.806976e+01 | "1980" 9.673356e+01 9.806976e+01 9.806976e+01 | ||
</file> | </file> | ||
+ | |||
+ | Note the use of the ''firstCol=2'' for objects of rank 2 or greater. See the [[howtos:workwithdata:export_quick_reference#tab_delimited_text_odometer_block_format|corresponding export call]]. | ||
===== TOOL file ===== | ===== TOOL file ===== |