mardi 21 avril 2015

scala read file and split and then save into val

I have a hello.txt

hello.txt

     [,1]
1       2
2       2
5      12
6       4

and here is scala code:

val textFile = sc.textFile("/home/winsome/share/hello.txt")
val ratings = textFile.map { line => 
    val fields = line.split(" ")  
    val (id, linksStr) = (fields(0).toInt, fields(1).toInt)
    println(id)        //1 2 5 6
    printlin(linkStr)  //2 2 12 4
 }

println(id) and printlin(linkStr) do nothing , Please tell me how to display the format I want
thank you

Aucun commentaire:

Enregistrer un commentaire