I need to print particular row from web table like
Input
John
Output
John Teacher 30
hi,
like this way
//get instance of internal datafile
InternalData data = findTestData('SpamData/someSpamTestData')
//int colNumbers = data.columnNumbers
//get column names from the datafile
def colNames = data.columnNames
println "column names "+colNames
int row = 1 //values start from row 1
int colCount = 0
List<String> allValues = new ArrayList<>()
def searchString = "dog"
int colIndex = 1
//loop rows
for (def index : (0..data.getRowNumbers() - 1)) {
//loop columns
for (int x = 1; x < colNames.size()+1; x++){
//check is there value in the column cell
if (data.getValue(x, row).equals(searchString)){
for (String header :colNames){
//println "header: "+header+ " row: "+row+" value: "+data.getValue(colIndex++, row)
allValues.add(data.getValue(colIndex++, row))
}
println allValues
break
}
}
row++
}
[dog, mouse, cat, pen]
//print as string
def wantedString = allValues.get(0)+" “+allValues.get(1)+” “+allValues.get(2)+” "+allValues.get(3)
println wantedString
dog mouse cat pen
//print with dynamic way
String ss = ""
for (int c = 0; c < colNames.size(); c++){
ss += allValues.get(c)+" "
}
print ss
dog mouse cat pen