[Solved] Given the file path find the file extension using Scala?

You could achieve this as follows: import java.nio.file.Paths val path = “/home/gmc/exists.csv” val fileName = Paths.get(path).getFileName // Convert the path string to a Path object and get the “base name” from that path. val extension = fileName.toString.split(“\\.”).last // Split the “base name” on a . and take the last element – which is the extension. … Read more

[Solved] How to summarize lists in Scala?

You’re looking for the transpose method: scala> val in = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9)) in: List[List[Int]] = List(List(1, 2, 3), List(4, 5, 6), List(7, 8, 9)) scala> in.transpose res0: List[List[Int]] = List(List(1, 4, 7), List(2, 5, 8), List(3, 6, 9)) scala> in.transpose.map(_.sum) res1: List[Int] = List(12, 15, 18) solved How … Read more