May be this is what you are looking for the line numbers containing the String, [CS_RES]
Let us put your dataframe
data in a text file, datafile.txt
in the
current directory of scala
. Then,
val lines = io.Source.fromFile("datafile.txt").getLines.toArray
will read all lines into lines
array of strings, Array[String]
.
Now the following command will process lines containing the desired
string and returns a list of line numbers containing [CS_RES]
. I checked
this command placing the sample data
you provided in the question
and it is giving me a List[Int]
with line numbers 1,3 and 8
.
scala> lines.map(x=>if(x.matches(""".*[CS_RES].*"""))
(lines.indexOf(x)+1)else 0).toList.filter(_!=0)
res50: List[Int] = List(1, 3, 8)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…