Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import au.com.bytecode.opencsv.CSVReader
import java.io.FileReader
import scala.collection.JavaConversions._
import java.util.UUID
import java.text.SimpleDateFormat
val format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss")
case class Stock(data: Array[String]) {
println(data.mkString(","))
val bd_id = data(0)
val level_0_id = UUID.fromString(data(1))
val level_1_id = UUID.fromString(data(2))
val level_2_id = UUID.fromString(data(3))
val level_3_id = UUID.fromString(data(4))
val level_4_id = UUID.fromString(data(5))
val respondent_id = data(6) // string
val title = data(7) // string
val partnerid = data(8).toInt //
val product_name = data(9)
val ndescription = data(10)
val length = data(11).toInt
val language = data(12)
val public_flag = data(13)
val airdate = if (data(14) == "t") true else false
val rundate = format.parse(data(15).split('.')(0))
val createdate = format.parse(data(16).split('.')(0))
val modifydate = format.parse(data(17).split('.')(0))
val gender_id = UUID.fromString(data(18))
val age = data(19).toInt
val region_id = data(20)
val zip = data(21)
val ethnicity_id = data(22)
val children_id = data(23)
val income_id = data(24)
val ace_score = data(25)
val persuasion_score = data(26)
val watchability_score = data(27)
val surfingwatchability = data(28)
val casualwatchability = data(29)
val favoritewatchability = data(30)
val relevance_score = data(31).toDouble
val information_score = data(32).toDouble
val innovation_score = data(33).toDouble
val attention_score = data(34).toDouble
val desire_score = data(35).toDouble
val liking_score = data(36).toDouble
}
import scala.io._
val inputFile = "/Users/fabrizio/hive/live_score_00001-00500"
val reader = new CSVReader(new FileReader(inputFile), '|', '\"', 1)
Stock(reader.readNext())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment