Differences

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

Link to this comparison view

Next revision
Previous revision
Last revision Both sides next revision
lesson_8 [2019/07/09 18:43]
argemiro created
lesson_8 [2020/02/11 22:08]
hermann [LESSON 8: Inserting and getting a specific value into a table]
Line 1: Line 1:
 {{ :​logo_logo.png?​400 |}} {{ :​logo_logo.png?​400 |}}
 \\ \\
-=====MODULE III: Working with tables on Dinamica EGO===== 
 \\ \\
-Work with tables is critical in data manipulation ​and most of these operations can be performed on Dinamica EGO. +====LESSON 8: Inserting ​and getting a specific value into a table====
 \\ \\
-=====LESSON 9: Inserting ​specific valuecreating a new column ​and retrieving a data column=====  ​+The aim of this lesson is getting and inserting specifics values from and into table on Dinamica. We will use the [[Get Table Value]] [[Set Table Cell Value]][[Add Table Column]], [[Set Table By Key]] and [[Get Table From Key]] functors and the following files:
 \\ \\
-==This lesson is focused on helping you to get and insert a specific value into a table on Dinamica.== 
 \\ \\
-**Which Functors will you use in this lesson?**\\ \\ +  ​The IBGE crop information Table (''​Guidebook_Dinamica_5\Database\Tables\IBGE_crop_information.csv''​) 
-• Functors:​ Get Set Table Value, Add table column set table by key and Get table from key +  * The 1999_production_value Table (''​Guidebook_Dinamica_5\Database\Tables\1999_production_value.csv''​) 
 +  * The 1999_harvested_area ​Table (''​Guidebook_Dinamica_5\Database\Tables\1999_harvested_area.csv.csv''​) 
 +  * The 1999_production Table (''​Guidebook_Dinamica_5\Database\Tables\1999_production.csv''​)
 \\ \\
 +**Let'​s go!** 
 \\ \\
-We will use: The IBGE crop information ​Table (Dinamica EGO\Guidebook Dinamica_4\Database\Tables\IBGE_crop_information.csv)+  * From the Input/​Output tab, grab a [[Load ​Table]] and place it on the sketch. Double click it, browse to the folder ''​Guidebook_Dinamica_5\Database\Tables''​ and open the ''​IBGE_crop_information.csv''​ file.
 \\ \\
 \\ \\
-**Let'​s go!** Click on the Input/​output tab from the library window, grab a Load Table and place it on the sketch. Double click, browse to the folder Dinamica EGO\Guidebook Dinamica_4\Database\Tables and open the IBGE_crop_information.csv file.+{{ :imagem32.png?800 |}}
 \\ \\
 \\ \\
-Click on the Input/output tab from the library window, grab a Load Table and place it on the sketch. Double click, browse to the folder Dinamica EGO\Guidebook Dinamica_4\Database\Tables and open the IBGE_crop_information.csv file.+<note important>​ 
 +Only multi-column CSV - comma separated value format is accepted 
 +</note>
 \\ \\
 +  * The first two columns are considered the keys of the file, being used to access a certain data in the table. Click on eye button of [[Load Table]] to see the table. ​
 \\ \\
-{{ :​imagem32.png?​600 |}} 
 \\ \\
 +{{ :​imagem33.png?​600 |}}
 \\ \\
-<note warning>​**ATTENTION:​** Only multi-column CSV - comma separated value format, is accepted</​note>​ 
 \\ \\
 +  * Grab a [[Get Table Value]] and place it on the sketch. Connect [[Load Table]] to [[Get Table Value]]. ​
 \\ \\
-The first two columns are considered the keys of the file, being used to access a certain data in a table. Click on eye button of “Load Table” to see the Table: ​ 
 \\ \\
 +{{ :​imagem34.png?​300 |}}
 \\ \\
-{{ :imagem33.png?600 |}}+  * Double click the Get Table Value to enter the keys corresponding to the sought-after values and the column name (highlighted by an asterisk). In the box Keys, enter ''​2001''​. Next, enter ''​1''​ (The Key to identify the wanted value on the table). Also, in the Column tab, add ''​4'',​ i.e., the column name or index where the value is located.
 \\ \\
 \\ \\
-In the next step, grab a Get Table Value and place it on the sketch. Connect the functor Load Table in the Get Table value+{{ :imagem35.png?300 |}}
 \\ \\
 \\ \\
- {{ :​imagem34.png?​600 |}} +<​note>​ 
-Double click the Get Table Value for indicate ​the Keys corresponding to the certain value and Column name (highlighted by an asterisk). In the box “Keys”enter “2001”. Next, enter “1” (The Keys to identify ​the desired value on the table). Also add “4”i.e., the column name or index where the value is located:+If the given keys are not found in the input table and the __Value If Not Found__ parameterin the Advanced Tabis not provided, an error will be reported. 
 +</​note>​
 \\ \\
 \\ \\
-{{ :imagem35.png?600 |}}+  * From the Table tab, grab a [[Calculate Value]] and place it on the sketch. Assign a number to [[Number Value]] and connect the [[Get Table Value]] to [[Number Value]]. In the Connect ports window, select __Value__
 \\ \\
-\\ 
-<note tip>​**TiP:​** If the given keys are not found in the input table and the “Value If Not Found” parameter is not provided, an error will be reported.</​note>​ 
-\\ 
-\\ 
-Click on the Table tab from the library window and grab a Calculate Value and place it on the sketch. Assign a number to Number value and connect the functors Get Table Value and Number value. In the “connect port” window, select “Value”. ​ 
- \\ 
 \\ \\
 {{ :​imagem36.png?​600 |}} {{ :​imagem36.png?​600 |}}
 \\ \\
 \\ \\
-Double-click on Calculate ​value to add a logic or an algebraic expression ​to calculate a value employing it. We divide v1 (the selected value) by 1000 and click OK.+  * Double-click on [[Calculate ​Value]] ​to add a logic or an algebraic expression. We divide v1 (the selected value) by 1000, ''​v1/​1000'', ​and click OK.
 \\ \\
 \\ \\
- {{ :​imagem37.png?​600 |}}+{{ :​imagem37.png?​300 |}}
 \\ \\
 \\ \\
-Click on the Table tab from the library window and grab a Set Table Cell Value and place it on the sketch. Connect ​the container ​Calculate ​value and the functor ​Load Table to the Set Table Cell Value. ​ In the “connect port” ​window, select ​Value.+  * From the Table tab grab a [[Set Table Cell Value]] and place it on the sketch. Connect ​[[Calculate ​Value]] ​and [[Load Table]] to [[Set Table Cell Value]].  In the Connect Ports window, select ​__Value__ input port for the output of [[Calculate ​Value]].
 \\ \\
 \\ \\
Line 66: Line 64:
 \\ \\
 \\ \\
- Double-click ​on Set Table Cell value. To identify where the value is located, on the box “Keys”, ​enter 20011” (Corresponding ​to Year 2001 and Crop 1) and add the index “4+  * Double-click ​[[Set Table Cell Value]]. To identify where the sought-after ​value is located, on the __Keys__ input enter ''​2001''​''​1'' ​(corresponding ​to Year 2001 and Crop 1) and add the Index ''​4''​ on the __Column__ input
- \\+\\
 \\ \\
 {{ :​imagem39.png?​600 |}} {{ :​imagem39.png?​600 |}}
 \\ \\
 \\ \\
-Click on the Input/output ​tab from the library window and grab a Save Table” and place it on the sketch. Connect ​the functor ​Set Table Cell Value to Save Table. \\ \\ +  * From the Input/Output ​tabgrab a [[Save Table]] and place it on the sketch. Connect ​[[Set Table Cell Value]] to [[Save Table]], select a folder and chose file name (e.g.  ​IBGE_crop_information_update.csv). ​The final model will look like this: 
-Now you need to save the result to a file. Open Save Map, select a folder and write a name file to save (suggestion: ​ ​IBGE_crop_information_update.csv). +\\ 
-\\+
 \\ \\
 {{ :​imagem40.png?​600 |}} {{ :​imagem40.png?​600 |}}
 \\ \\
 \\ \\
-  +{{ :imagem41.png?​600 |}}
-Mark the eye button at the top of “Save Table” to viewer the results hereafter. \\ \\ +
-The final model will look like this+
 \\ \\
 \\ \\
-{{ :imagem41.png?600 |}}+  * Save and run your model. Select the [[Save Table]] functor and click on the eye button to see the result.
 \\ \\
 \\ \\
-  
-Save your model (Disk button on the main tool bar) and then run it by clicking on the run button (blue arrow on the main tool bar). \\ \\ 
-Now, click on eye button of “Save Table” to see the result. This functor output is table that looks like this:\\ 
- 
 {{ :​imagem42.png?​600 |}} {{ :​imagem42.png?​600 |}}
-  +\\ 
-What is your model doing? It is loading “IBGE_crop_information.csv” file and then getting and inserting a specific value into a table. The new table will be saved with a crop 1 on year 2001 been divided by 1000. +\\ 
- +===Congratulations,​ you have successfully completed this lesson!=== ​ 
 +\\ 
 +☞[[:​lesson_9 | Next Lesson]] 
 +\\ 
 +☞[[:​guidebook_start| Back to Guidebook Start]] ​