I would like to read csv file in scala.

[![enter image description here](https://i.stack.imgur.com/D1OJC.png)](https://i.stack.imgur.com/D1OJC.png)

```
  val rows = ArrayBuffer[Array[String]]()

      using(io.Source.fromFile("test.csv")) { source =>
        for (line <- source.getLines) {
          rows += line.split(",").map(_.trim)
          }
        }     
      def using[A <: { def close(): Unit }, B](resource: A)(f: A => B): B =
         try {
            f(resource)
         }finally {
            resource.close()
            } 

```

I used above code to read csv file.

I get ArrayBuffer(Array[String]) now, but I want to get ArrayBuffer(Array[Double]).

toDouble method is wrong

What's the ideal way to do?

Thank you for your time.