Skip to content

How do I get number of records from a data file

This example demonstrates fetching the number of rows in a dataset after reading the data 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 total number of rows is fetched from the dataset using "ddGetRowCount" command and stored into a variable.

Solution:
# 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
Getting the number of rows from the dataset
3ddGetRowCount InsuranceDetails Row_Count

Tips, Tricks, Gotchas & Best Practices: 

  • You should use the same dataset name which is created by using "ddCreateDataSet" command in "ddCreateDatasetFromADatafile" and "ddGetRowCount" 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