This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | Next revision Both sides next revision | ||
howtos:workwithdata:createsetsfromdatafile [2011/05/13 12:46] shona.weldon |
howtos:workwithdata:createsetsfromdatafile [2011/05/13 12:47] shona.weldon |
||
---|---|---|---|
Line 89: | Line 89: | ||
===== Example Test Load ===== | ===== Example Test Load ===== | ||
- | Once you have code for reading the sets it's often useful to do a quick test load of the data | + | Once you have code for reading the sets it's often useful to do a quick test load of the data. This file pulls together all the pieces: |
+ | |||
+ | <file> | ||
+ | $informPath = $home + "/V4/informants" | ||
+ | |||
+ | string $importPath, $fileName | ||
+ | buildstring ($importPath, $home, "/testScripts") | ||
+ | |||
+ | buildstring ($fileName, $importPath, "/emtestfile.csv") | ||
+ | |||
+ | localinformant ECemRowTitles[] = create (; object=set, delimiter=",", \ | ||
+ | allowDuplicate=on, \ | ||
+ | elemNamesFromColNum=2, firstLine=11, \ | ||
+ | searchElemName1="", replaceElemName1="blank", \ | ||
+ | searchElemName2="&", replaceElemName2="and", \ | ||
+ | replaceWhiteSpaceInElemName="_" , \ | ||
+ | file=$fileName) | ||
+ | display (ECemRowTitles[]) | ||
+ | export (ECemRowTitles[]; file=$importPath/ECemRowTitles.txt) | ||
+ | |||
+ | |||
+ | localinformant GHGInvEmType[] = create (; object=set, delimiter=",", \ | ||
+ | allowDuplicate=on, \ | ||
+ | elemNamesFromLineNum=6, firstCol=3, \ | ||
+ | searchElemName1="", replaceElemName1="blank", \ | ||
+ | searchElemName2="&", replaceElemName2="and", \ | ||
+ | replaceWhiteSpaceInElemName="_" , \ | ||
+ | file=$fileName) | ||
+ | |||
+ | display (GHGInvEmType[]) | ||
+ | export (GHGInvEmType[]; file=$importPath/GHGInvEmType.txt) | ||
+ | |||
+ | local data[rows,cols] = create (; dim=ECemRowTitles, dim=GHGInvEmType, \ | ||
+ | dataFormat="coordinate", fileFormat="text", allCoord=off, delimiter=",", \ | ||
+ | firstLine=11, firstCol=2, ignoreExtraCols=on, ignoreMissingCols=on, \ | ||
+ | searchData=",", replaceData="" , \ | ||
+ | searchElemName1="", replaceElemName1="blank", \ | ||
+ | searchElemName2="&", replaceElemName2="and", \ | ||
+ | replaceWhiteSpaceInElemName="_" , \ | ||
+ | file=$fileName) | ||
+ | |||
+ | table (data[rows,cols]) | ||
+ | </file> |