What would be a good strategy to map test cases between different macros using csv?

Like TestCase1 has two rows , one in Vehicles.csv and other in Coverages.csv
My intention is to pass Global Variables as TestCaseName and CSVName and then run a loop like…

if(maxrowcount>1)
{
do
{
//${!COL1} means TestCaseNames in COL1 for each row

if({!COL1} != GlobalTestCaseName (it would be redefined for each sub macro) { !csvReadLineNumber={!csvReadLineNumber}+1 csvRead(GlobalCSVFile) } repeat if({!COL1} != GlobalTestCaseName && csvReadLineNumber<=maxrowcount)

If its found , then it should check whether the same test case has one or more than rows in the csv file

if(${!COL1} == GLOBAL)
{
do
{
performing some action like adding vehicles
}
repeat if(csvReadLineNumber<=maxrowcount && {!COL1==GlobalTestCaseName})
}
}
}

I’m checking for three conditions here

  • If there is no matching test case in other macro’s csv , it should return ,
    Search shouldnt exceed the maximum number of rows while reading csv.
    It should loop if its finds more than row for the matching test case like
    TestCase7
    TestCase7

any suggestions on improvement would be deeply appreciated @newuserkantu/@admin
Thanks a lot