LESSON 8: Inserting and getting a specific value into a table


The aim of this lesson is getting and inserting specifics values from and into a 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:

  • The IBGE crop information Table (Guidebook_Dinamica_5\Database\Tables\IBGE_crop_information.csv)
  • 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!

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





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 the table. Click on eye button of Load Table to see the table.








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





If the given keys are not found in the input table and the Value If Not Found parameter, in the Advanced Tab, is not provided, an error will be reported.







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









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





  • From the Input/Output tab, grab a Save Table and place it on the sketch. Connect Set Table Cell Value to Save Table, select a folder and chose a file name (e.g. IBGE_crop_information_update.csv). The final model will look like this:







  • Save and run your model. Select the Save Table functor and click on the eye button to see the result.





Congratulations, you have successfully completed this lesson!