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
lesson_7 [2019/08/13 17:14]
argemiro
lesson_7 [2020/02/11 21:51]
hermann
Line 1: Line 1:
 {{ :​logo_logo.png?​400 |}} {{ :​logo_logo.png?​400 |}}
 \\ \\
- 
 \\ \\
-=====LESSON 7: Creating a new column and retrieving a data column from the specified table=====  ​ +====LESSON 7: Creating a new column and retrieving a data column from tables==== 
-\\ \\ +\\ 
-**Now, Go ahead** to create a new column in the given table+  To create a new column in given table we must open all the files that will be used to retrieve data from. Click on the Input/​Output tab from the library window and grab three [[Load Lookup Table]] Functors and one [[Load Table]] placing them on the sketch. Open the [[Load Lookup Table]] functors and load the files ''​1999_production_value.csv'',​ ''​1999_harvested_area.csv''​ and ''​1999_production.csv''​ from the folder ''​Guidebook_Dinamica_5\Database\Tables\''​. Next, open [[Load Table]] and load ''​IBGE_crop_information_uptated.csv''​.
 \\ \\
 \\ \\
-We must open all the files that will be used. Click on the Input/​output tab from the library window and grab three “Load Lookup Table” Functors and one “Load Table” and place it on the sketch. Open the Load Lookup Table functors and load the files 1999_production_value.csv,​ 1999_harvested_area.csv and 1999_production.csv from folder “Tables”. Next, Open the Load Table functor and load the file IBGE_crop_information_uptated.csv. 
 {{ :​imagem43.png?​200 |}} {{ :​imagem43.png?​200 |}}
 \\ \\
 \\ \\
-Nowcan create a new column merge with 1999_harvested_area.csv and 1999_production.csv files. ​Click on the Input/output ​tab from the library window and grab Add Table Column and place it on the sketch. Connect the Load Lookup Table which contains the file 1999_harvested_area.csv to Add Table Column. On the Functor Editor window, write a name for the created column (it can be “production_value”). ​+  * Now we can create a new column merge between the ''​1999_harvested_area.csv'' ​and ''​1999_production.csv'' ​files. ​On the Input/Output ​tabgrab an [[Add Table Column]] and place it on the sketch. Connect the [[Load Lookup Table]] which contains the file ''​1999_harvested_area.csv'' ​to [[Add Table Column]], selecting __Table__ as an input port. On the Functor Editor window, write a name for the created column (e.g. “production_value”). ​
 \\ \\
 \\ \\
-<note important>​**IMPORTANT:​** ​The position where the new column is inserted determines whether the new column is a key or data column.</​note>​+<note important>​ 
 +The position where the new column is inserted determines whether the new column is a key or data column. 
 +</​note>​
 \\ \\
 \\ \\
Line 21: Line 21:
 \\ \\
 \\ \\
-Connect the Load Lookup Table which contains the file 1999_production.csv to Add Table Column. ​Finallyconnect ​the Load Lookup Table which contains the file IBGE_crop_information_uptated.csv to Set Table by Key. +  * Connect the [[Load Lookup Table]] which contains the file ''​1999_production.csv'' ​to [[Add Table Column]], the __Column Values__ port will be automatically assigned as an input port. 
-Now you need to save the result to a file. For thisopen Save Map functor and browse to the Dinamica EGO\Guidebook Dinamica_4\Models\Set_2\basics\ ​to determine where the file will be saved and write the name file (Suggestion: “IBGE_crop_information_complete.csv”).\\ \\ +\\ 
-Mark the eye button at the top of “Save Table” to viewer the results hereafter. \\ \\ +  * Add another [[Add Table Column]] to the sketchassign ​the output of the previous [[Add Table Column]] to the __Table__ input port of the recently added functor. Connect the [[Load Lookup Table]] with ''​1999_production_value.csv'' ​to the new [[Add Table Column]]. In the Functor Editor window, choose a name for the created column (e.g. "​production"​).  
-Click on the layout tool Left to Right and your final model will look like the one below: \\ \\+\\ 
 +  * Add a [[Set Table By Key]] to the sketch, assign the output of [[Add Table Column]] to the __Subtable__ input port of [[Set Table By Key]] and the [[Load Table]] with ''​IBGE_crop_information_uptated.csv'' ​to the __Table__ port. In the Functor Editor window, enter ''​1999''​ as the key identifying the sub-table that will be updated or inserted. Additionally,​ toggle the __Ignore Column Names__ flag in the Functor Editor Window. 
 +\\ 
 +  * To save the result to a file, place a [[Save Table]] on the sketch, ​browse to ''​Guidebook_Dinamica_5\Models\Set_2\basics\'' ​and write the file name (e.g. ''​IBGE_crop_information_complete''​).  
 +\\ 
 +  ​* ​Click on the layout tool Execute Layout. Your final model should be similar to the one below: ​ 
 +\\  
 +\\
 {{ :​imagem45.png?​500 |}} {{ :​imagem45.png?​500 |}}
 \\ \\
 \\ \\
-Save and run the model! \\ +  * Save and run the model. Select the [[Save Table]] functor and click on the eye button to open the resulting ​table.
-Now, click on eye button ​of “Save Table” ​to see the result. This functor output is table that looks like this:+
 \\ \\
 \\ \\
Line 35: Line 41:
 \\ \\
 \\ \\
-Now, using the table generated previously, we would like to demonstrate how to retrieves ​a data column from the specified table.+ 
 +---- 
 + 
 +Using the table generated previously, we would like to demonstrate how to retrieve ​a data column from it.
 \\ \\
 \\ \\
-First, grab Load Table” and place it on the sketch. Double click the Load Table Functor ​and open the IBGE_crop_information_complete.csv ​file.+  * Grab [[Load Table]], placing ​it on the sketch. Double click it and open the file generated in last step (e.g. ''​IBGE_crop_information_complete.csv''​).
 \\ \\
 \\ \\
- {{ :​imagem47.png?​500 |}}+{{ :​imagem47.png?​500 |}}
 \\ \\
 \\ \\
- +  * To retrieve ​data column corresponding to the harvested area, we will use [[Get Table Column]]. Connect the [[Load Table]] to [[Get Table Column]]. In the input __Column ​Index or Name__ of the Functor Editor window, insert the index of the column to be retrieved (“3” or “harvested area”).
-Now, we can retrieve data column ​table corresponding to harvested area. For thisgrab a “Get Table Column ​functor” and place it on the sketch. Connect the Load Table to Get Table Column. In the tab “Column ​Index or Name”, insert the index of the column to be retrieved (“3” or “harvested area”). +
-  ​+
 \\ \\
 \\ \\
Line 52: Line 59:
 \\ \\
 \\ \\
-Now, we can retrieve the harvested area per crop corresponding to 2004 year.  For this, grab a Get Table from key” ​and place it on the sketch. Connect ​the Get Table Column to Get Table from Key. In the tab “Keys”, insert the year you want to retrieve the harvested area per crop (In this example, “2004”).+  * Now, we can retrieve the harvested area per crop corresponding to the year of 2004.  For this, grab a [[Get Table from Key]] and place it on the sketch. Connect ​[[Get Table Column]] to [[Get Table from Key]]. In the input __Keys__ of the Functor Editor window, insert the year you want to retrieve the harvested area per crop (in this example, “2004”).
 \\ \\
 \\ \\
Line 58: Line 65:
 \\ \\
 \\ \\
- +  * Grab [[Save Table]] and place it on the sketch. Connect ​[[Get Table From Key]] and [[Save Table]]. The final model should have the following structure
-Now, grab Save Table” and place it on the sketch. Connect ​the functor ​Get Table from Key and Save Table. The final model will look like this+
 \\ \\
 \\ \\
Line 65: Line 71:
 \\ \\
 \\ \\
-  +  * To save the result to a file, edit [[Save Table]], browse to ''​GuideBook_Dinamica_5\Models\Set_2\basics\ Get_Table_from_Key'' ​and write the file name (e.g. IBGE_crop_information_update).
-Now you need to save the result to a file. Open Save Map, browse to the Documents\GuideBook Dinamica\Guidebook Dinamica_4\Models\Set_2\basics\ Get_Table_from_Key and write the name file (it can be IBGE_crop_information_update.csv).+
 \\ \\
 \\ \\
Line 72: Line 77:
 \\ \\
 \\ \\
-  +  * Save and run the model. To see the resulting table, click on eye button of [[Save Table]]This functor output is a table that looks like this:
-Mark the eye button ​at the top of Save Table” to viewer the results hereafter +
-Click on the layout tool Left to Right and your final model will look like the one below +
- \\+
 \\ \\
-{{ :​imagem52.png?​500 |}} 
 \\ \\
 +{{ :​imagem53.png?​300 |}}
 \\ \\
- 
-Save and run the model! 
-Now, click on eye button of “Save Table” to see the result. This functor output is table that looks like this: 
 \\ \\
 +==== Congratulations,​ you have successfully completed this lesson! ====
 \\ \\
-{{ :imagem53.png?​300 ​|}}+☞[[:lesson_8 ​Next Lesson]]
 \\ \\
-\\ +☞[[:​guidebook_start| Back to Guidebook Start]] ​
- +
- +
- +