Forum Discussion

Mis3's avatar
Mis3
Frequent Contributor
3 years ago
Solved

Groovy Script to read a CSV

My Groovy script has a loop to read an CSV file and to execute the testcases one by one.  It is working but I like to improve its efficiency. If the CSV has blank lines, the testcase would still exe...
  • nmrao's avatar
    nmrao
    3 years ago
    Ok.
    Instead of data[0].charAt[0], try using
    if (rowdata.startsWith('3')) {
    // do all the processing here
    }
  • Mis3's avatar
    Mis3
    3 years ago

    Thanks, nmrao.

    I used your code but modified it a bit.   I also added a continue statement so to ignore the rest of the code like testcase, etc.

     

    if ( !rowdata.startsWith('302') )
    {
    log.info " Seq="+i+ " " + data[0]+" Invalid line"
    report << "\n"+ sdf.format(log_date)+" Seq="+i+ " " + data[0] +" Invalid line"
    continue
    }