WebTable- Fetch particular Data

Need to Fetch data from table
input - Egypt (Need particular value of Entity Type when IsDefault is ‘1’)

Data

My code is:

def input = “Mark”

TestData data = findTestData(‘New Test Data’)

data.changeSheet(‘Entity Types’)
for (int excelRow : (1…data.getRowNumbers())) {
‘country in loop’
selectcountry = data.getValue(‘Name’,excelRow)
println "Looppppppp "+selectcountry

'if country is egypt'
if(selectcountry==input){
	
	println "seectcountryyyyy  "+selectcountry
	
	'IsDefault in loop'
	for (int selectval : (1..data.getRowNumbers())) {
		selectval1 = data.getValue('IsDefault', selectval)
		println "value with 1    " +selectval1
	
	'If is default is 1'
	if(selectval1=="1"){
		ent = data.getValue('EntityType',selectval )
		
		println "entttttttt " +ent
		
		break
		
	}
	
	}
}
		
}

but unable to fetch entity type English pls help me

hi,

this will find Mark & 1
def input = “Mark”

    TestData data = findTestData('Data Files/SpamData/FetchParticularData')

    boolean found = false
    	
    	for (int excelRow : (1 ..  data.getRowNumbers())) {
    		
    		for (int columns :(1 .. data.getColumnNumbers())){
    			
    			if ((data.getValue(columns, excelRow).equals(input)) && (data.getValue('IsDefault', excelRow).equals('1')) ){
    				
    				println("English found!!!"+columns+" "+excelRow+" "+data.getValue('IsDefault', excelRow))
			println("Name: "+data.getValue('Name', excelRow)+" Country: "+data.getValue('Country', excelRow)+ " CountryId: "+data.getValue('CountryId', excelRow)+" EntityType: "+
				data.getValue('EntityType', excelRow)+" IsDefault: "+data.getValue('IsDefault', excelRow))
    				found=true
    				break
    			}
    			else{
    				println("English not found!!!")
    			}
    			
    		}
    		if(found){
    			break
    		}
    	}

English found!!!1 4 1 (column 1, row 4, and IsDefault = 1)
Name: Mark Country: IN CountryId: 23 EntityType: English IsDefault: 1

1 Like

Thank you so much , its really helpful. but I need to print as “English”

when input = Mark
IsDefault is 1 then
Entity Type is English

output == English

hi,

this is already there
output == English
println(data.getValue(‘EntityType’, excelRow))
or get it to the variable
def entity = data.getValue(‘EntityType’, excelRow)
println(entity)

1 Like

Excellent! Just noticed previous reply of yours,You gave me a complete solution . Thanks much.