This is an old revision of the document!


PHP's gd library is missing or unable to create PNG images



LESSON 8: Inserting a specific value and retrieving a data column


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?

• Functors: Get Set Table Value, Add table column set table by key and Get table from key



We will use:
-The IBGE crop information Table (Dinamica EGO\Guidebook Dinamica_4\Database\Tables\IBGE_crop_information.csv)

-The 1999_production_value Table (Dinamica EGO\Guidebook Dinamica_4\Database\Tables\1999_production_value.csv)

-The 1999_harvested_area Table (Dinamica EGO\Guidebook Dinamica_4\Database\Tables\1999_harvested_area.csv.csv)

-The 1999_production Table (Dinamica EGO\Guidebook Dinamica_4\Database\Tables\1999_production.csv)


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.

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.



ATTENTION: Only multi-column CSV - comma separated value format, is accepted



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:



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.

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:



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.



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”.



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.



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”.



Double-click on Set Table Cell value. To identify where the value is located, on the box “Keys”, enter “2001”, “1” (Corresponding to Year 2001 and Crop 1) and add the index “4”.



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.

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).



Mark the eye button at the top of “Save Table” to viewer the results hereafter.

The final model will look like this:



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: