User Tools

Site Tools


howtos:workwithdata:createsetsfromdatafile

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
howtos:workwithdata:createsetsfromdatafile [2011/05/13 12:46]
shona.weldon
howtos:workwithdata:createsetsfromdatafile [2015/06/22 15:42]
marcus.williams [Example Test Load]
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>​ 
 + 
 +And here's a growing list of "​magic"​ element name character replacements:​ 
 + 
 +<​file>​ 
 + 
 +localinformant NHS2011Profile_fld[] = create (; object=set, delimiter=",",​ \ 
 + allowDuplicate=off,​ \ 
 + elemNamesFromColNum=2,​ firstLine=1,​ \ 
 + searchElemName1=",",​ replaceElemName1="",​ \ 
 + searchElemName2="​.",​ replaceElemName2="​_",​ \ 
 + searchElemName3="&",​ replaceElemName3="​and",​ \ 
 + searchElemName4="/",​ replaceElemName4="​_",​ \ 
 + searchElemName5="​(",​ replaceElemName5="",​ \ 
 + searchElemName6="​)",​ replaceElemName6="",​ \ 
 + searchElemName7="​]",​ replaceElemName7="",​ \ 
 + searchElemName8="​[",​ replaceElemName8="",​ \ 
 + searchElemName9="​-",​ replaceElemName9="​_",​ \ 
 + searchElemName10="'",​ replaceElemName10="",​ \ 
 + searchElemName11="​$",​ replaceElemName11="​dlr",​ \ 
 + searchElemName12="​%",​ replaceElemName12="​pct",​ \ 
 + searchElemName13=":",​ replaceElemName13="",​ \ 
 + stripLeadingWhiteSpace=off,​ \ 
 + replaceWhiteSpaceInElemName="​_"​ , \ 
 + file=$fileName) 
 + 
 +</​file>​
howtos/workwithdata/createsetsfromdatafile.txt · Last modified: 2015/06/22 15:46 by marcus.williams