Advertisement
Guest User

Untitled

a guest
Jan 28th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.82 KB | None | 0 0
  1. import scala.io.Source
  2. import elections._
  3. object Zad2 extends App {
  4.  
  5.   val wojewodztwa = Source
  6.     .fromResource("wojewodztwa.csv")
  7.     .getLines
  8.     .toList
  9.     .map(l => {
  10.       l.split(",").toList match {
  11.         case List(a, b) => Województwo(a, b.toInt)
  12.       }
  13.     })
  14.  
  15.   val gminy = Source
  16.     .fromResource("gminy.csv")
  17.     .getLines
  18.     .toList
  19.     .map(l => {
  20.       l.split(",").toList match {
  21.         case List(name,id,votes) => Gmina(name,id.toInt,votes.toInt)
  22.       }
  23.     })
  24.  
  25.  
  26.   val wyniki = Source
  27.     .fromResource("wyniki.csv")
  28.     .getLines
  29.     .toList
  30.     .map(l => {
  31.       l.split(",").toList.map(_.toInt) match {
  32.         case List(id,a,b,c,d,e,f,g,h,i,j) => Wynik(id,a,b,c,d,e,f,g,h,i,j)
  33.       }
  34.     })
  35.  
  36.   val agregatedResults = wyniki.groupBy(x => (x.ID /10000).toInt)
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement