I've written all the complex mumbo jumbo Scala logic but now I am stuck with a very very basic problem. java.io.FileNotFoundException.
I am trying to read from a csv file & feed that data as input to my Code.
My folder structure is:
MainProject
AcceptanceTest
com.myOwn
nish
data
TestData.csv
pagemodel
spec
Test.scala
util
Here's my file reading piece of code:
import scala.io.Source
class Test {
val testDataFile = Source.fromFile("./../data/TestData.csv")
for (line <- testDataFile.getLines().drop(1)) {
val cols = line.split(",").map(_.trim)
println(s"${cols(0)}|${cols(1)}|${cols(2)}")
}
TestData.csv contains:
#ScenarioName, Value1, Value2
Test1, F1, BrightnessDecrease
Test2, F2, BrightnessIncrease
Running Test.scala gives me a java.io.FileNotFoundException. If I change my File path to the absolute path, everything works ok.
val testDataFile = Source.fromFile("/MainProject/AcceptanceTest/com/myOwn/nish/data/TestData.csv")
What is missing in my relative path which I am unable to spot?