Skip to content

How do I get a specific cell value from a data file

This example demonstrates fetching the value of a specific cell from a data file.

In the solution shown below, a dataset is created with the specified data definition that holds the attributes of the data file using "ddCreateDataSet" command. The data from the data file is read into this dataset using "ddCreateDatasetFromADatafile" command. The value from the required cell is fetched in two ways, one is by index using "ddGetCellValueByIndex" command and the other is by name using "ddGetCellValueByName" command.

Solution:

Approach 1: Fetching the required cell value by index
# Command Target Value
Creating the dataset and specifying the data definition name of the data file
1ddCreateDataSet InsuranceDetails Insurance Details(W)
Reading the data from the data file into the dataset
2ddCreateDatasetFromADatafile Insurance Details(W) InsuranceDetails
Retrieving the cell value by index
3ddGetCellValueByIndex InsuranceDetails(0,0) age
Approach 2: Fetching the required cell value by name
# Command Target Value
Create a dataset from a data file
1ddCreateDataSet InsuranceDetails Insurance Details(W)
Create dataset from a data file
2ddCreateDatasetFromADatafile Insurance Details(W) InsuranceDetails
Retrieving the cell value by name
3ddGetCellValueByName InsuranceDetails(0,Age) age

Tips, Tricks, Gotchas & Best Practices: 

  • You should use the same dataset name which is created by using "ddCreateDataSet" command in "ddCreateDatasetFromADatafile", "ddGetCellValueByIndex" and "ddGetCellValueByName" commands.
  • You can also pass the data filter name along with the data file name using the separator "||" in "ddCreateDatasetFromADatafile" command to read only the filtered rows into the dataset from the data file. To know more about data filters click here.
  • You can optionally pass the status of the Data Definition and Data file along with their names in "ddCreateDataSet" and "ddCreateDatasetFromADatafile" commands respectively. Allowed values for status are 'W'(WIP) and 'A'(Active). If the status value is not passed, the status is assumed to be 'W'(WIP).
  • As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscores.

Feedback and Knowledge Base