This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
howtos:workwithdata:createsetsfromdatafile [2011/05/06 20:57] shona.weldon |
howtos:workwithdata:createsetsfromdatafile [2011/05/13 12:34] shona.weldon |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Use create to make informants from data file ====== | ====== Use create to make informants from data file ====== | ||
- | Here's a tar file with several examples and data. | + | |
- | * Download and un-zip it somewhere on your server where you have access to it with interactive tool, on any account. | + | |
- | * {{:howtos:workwithdata:create.zip|}} | + | |
- | * The best way to learn about the features is to work through the test.t script file in the above tar file looking at the results as you go. | + | |
===== Important parameters ===== | ===== Important parameters ===== | ||
==== General ==== | ==== General ==== | ||
Line 58: | Line 54: | ||
<code> | <code> | ||
- | string $importPath, $fileName | + | string $importPath, $fileName |
- | buildstring ($importPath, $home, "/testScripts") | + | buildstring ($importPath, $home, "/testScripts") |
+ | |||
+ | buildstring ($fileName, $importPath, "/emtestfile.csv") | ||
+ | localinformant ECemRowTitles[] = create (; object=set, delimiter=",", \ | ||
+ | allowDuplicate=on, \ | ||
+ | elemNamesFromColNum=2, firstLine=9, \ | ||
+ | searchElemName1=",", replaceElemName1="-", \ | ||
+ | searchElemName2="&", replaceElemName2="and", \ | ||
+ | replaceWhiteSpaceInElemName="_" , \ | ||
+ | file=$fileName) | ||
+ | display (ECemRowTitles[]) | ||
+ | export (ECemRowTitles[]; file=$importPath/ECemRowTitles.txt) | ||
+ | </code> | ||
+ | |||
+ | ==== Read from a line/row ==== | ||
+ | The following code reads the second column as | ||
+ | |||
+ | <code> | ||
+ | string $importPath, $fileName | ||
+ | buildstring ($importPath, $home, "/testScripts") | ||
+ | |||
+ | buildstring ($fileName, $importPath, "/emtestfile.csv") | ||
+ | localinformant GHGInvEmType[] = create (; object=set, delimiter=",", \ | ||
+ | allowDuplicate=on, \ | ||
+ | elemNamesFromLineNum=6, firstCol=4, \ | ||
+ | searchElemName1=",", replaceElemName1="-", \ | ||
+ | replaceWhiteSpaceInElemName="_" , \ | ||
+ | file=$fileName) | ||
+ | |||
+ | display (GHGInvEmType[]) | ||
+ | export (GHGInvEmType[]; file=$importPath/GHGInvEmType.txt) | ||
+ | </code> | ||
- | buildstring ($fileName, $importPath, "/emtestfile.csv") | + | ===== Example Test Load ===== |
- | localinformant ECemRowTitles[] = create (; object=set, delimiter=",", \ | + | Once you have code for reading the sets it's often useful to do a quick test load of the data |
- | allowDuplicate=on, \ | + | |
- | elemNamesFromColNum=2, firstLine=9, \ | + | |
- | searchElemName1=",", replaceElemName1="-", \ | + | |
- | searchElemName2="&", replaceElemName2="and", \ | + | |
- | replaceWhiteSpaceInElemName="_" , \ | + | |
- | file=$fileName) | + | |
- | display (ECemRowTitles[]) | + | |
- | export (ECemRowTitles[]; file=$importPath/ECemRowTitles.txt) | + | |
- | + | ||
- | <\code> | + |