Skip to content

Instantly share code, notes, and snippets.

@ken-itakura
Created October 4, 2016 07:14
Show Gist options
  • Save ken-itakura/f5fafd99179b64fc1271c6810a382b28 to your computer and use it in GitHub Desktop.
Save ken-itakura/f5fafd99179b64fc1271c6810a382b28 to your computer and use it in GitHub Desktop.
Read CSV and create Map
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