Created
October 4, 2016 07:14
-
-
Save ken-itakura/f5fafd99179b64fc1271c6810a382b28 to your computer and use it in GitHub Desktop.
Read CSV and create Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.io.Source | |
// Read CSV create and create Map | |
object DictSource2SeedDict extends App { | |
val csvFile = Source.fromFile("file_path", "utf8") | |
val listDict = Map(csvFile.getLines.toList.map{l => | |
val lc = l.split("\t") | |
(lc(0)->lc(1)) // assume first field is key and second field is value | |
}: _*) | |
println(listDict.get("key_string")) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment