Tennis Historical Data Retriever in Scala

Here’s a quick and dirty Tennis historical data retriever:

import java.util.Date
import java.text.SimpleDateFormat
object TennisDataAnalysis extends App{
  def wrapStringInt(stringInt:String) = if(stringInt=="") None else Some(stringInt.toInt)
  case class TennisMatch(location:String, tournament:String, date:Date, series:String,
                         surface:String, round:String, bestOf:Int, winner:String, loser:String,
                         W1:Option[Int], L1:Option[Int], W2:Option[Int], L2:Option[Int], W3:Option[Int],
                         L3:Option[Int], W4:Option[Int], L4:Option[Int], W5:Option[Int], L5:Option[Int],
                         Wsets:Option[Int], Lsets:Option[Int], comment:String)
  val sourceSite = ""
  val years = List(2010,2011,2012,2013)
  val tournaments = List("ausopen","frenchopen","usopen","wimbledon")
  val urls = => sourceSite+year+"/").flatMap(urlYear =>> urlYear+tours+".csv"))
  val data =
    urls.flatMap{urlYearTour =>
        .map{g => TennisMatch(g(1), g(2), new SimpleDateFormat("dd/mm/yyyy").parse(g(3)), g(4),
                          g(6),g(7),g(8).toInt, g(9), g(10),
                          wrapStringInt(g(15)), wrapStringInt(g(16)), wrapStringInt(g(17)), wrapStringInt(g(18)),
                          wrapStringInt(g(19)), wrapStringInt(g(20)), wrapStringInt(g(21)), wrapStringInt(g(22)),
                          wrapStringInt(g(23)), wrapStringInt(g(24)), wrapStringInt(g(25)), wrapStringInt(g(26)),

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s