testing1/alcohol.scala
changeset 152 16dbc95d7d77
parent 144 41a2b4f2c30c
child 161 bb43401d82c3
equal deleted inserted replaced
151:a1518a92469f 152:16dbc95d7d77
    26 get_csv_file(file_population).size
    26 get_csv_file(file_population).size
    27 
    27 
    28 val alcs = get_csv_page(url_alcohol)
    28 val alcs = get_csv_page(url_alcohol)
    29 val pops = get_csv_file(file_population)
    29 val pops = get_csv_file(file_population)
    30 
    30 
    31 
       
    32 def process_alcs(lines: List[String]) : List[(String, Double)] =
    31 def process_alcs(lines: List[String]) : List[(String, Double)] =
    33   for (l <- lines) yield {
    32   for (l <- lines) yield {
    34     val entries = l.split(",").toList 
    33     val entries = l.split(",").toList 
    35     (entries(0), entries(4).toDouble) 
    34     (entries(0), entries(4).toDouble) 
    36   }
    35   }
    39   (for (l <- lines) yield {
    38   (for (l <- lines) yield {
    40     val entries = l.split(",").toList 
    39     val entries = l.split(",").toList 
    41     (entries(0), entries(1).toLong)
    40     (entries(0), entries(1).toLong)
    42   }).toMap
    41   }).toMap
    43 
    42 
       
    43 
       
    44 process_alcs(alcs.drop(1))(1)
       
    45 process_pops(pops.drop(1))("Albania")
    44 
    46 
    45 def sorted_country_consumption() : List[(String, Long)] = {
    47 def sorted_country_consumption() : List[(String, Long)] = {
    46   val alcs2 = process_alcs(alcs.drop(1))
    48   val alcs2 = process_alcs(alcs.drop(1))
    47   val pops2 = process_pops(pops.drop(1))
    49   val pops2 = process_pops(pops.drop(1))
    48   val cons_list = 
    50   val cons_list =