This is small utility function in Scala, that takes fully qualified path of the properties file, and converts it into Map and returns. I use it for taking path of the properties file in my standalone Scala program and load it into Map
def getConfig(filePath: String)= {
Source.fromFile(filePath).getLines().filter(line => line.contains("=")).map{ line =>
println(line)
val tokens = line.split("=")
( tokens(0) -> tokens(1))
}.toMap
}
Once you have this method you can call it like this
getConfig(filePath)
3 comments:
Thanks for the post.
I want to get the filePath from arguments or from command line while submitting the jar. Can you help me how to achieve that.
Appreciate your help on this. Thanks in advance.
is possible to read property file in pyspark, that is my requirement, can u please help me any one
Its Pleasure to read your blog.The above articles is very impressive, and I really enjoyed reading your blog and points that you expressed. I love to come back on a regular basis,post more on the subject.
python internship | web development internship |internship for mechanical engineering students |mechanical engineering internships |java training in chennai |internship for 1st year engineering students |online internships for cse students |online internship for engineering students |internship for ece students|data science internships |
Post a Comment