scala - Spark mapping a flat file to a class -


i have flat file on hdfs containing list of companies

companya companya decription april '12 san fran 11-50 companyb ... 

and want map companies class

case class company(company: string,                     desc: string,                     founded: date,                     location: string,                     employees: string) 

i have tried following doesn't seem map properly

val companiestext = sc.textfile(...)  val companies = companytext.map(    lines => company(         lines(0).tostring.replaceall("\"", ""),         lines(1).tostring.replaceall("\"", ""),         lines(2).tostring.replaceall("\"", ""),         lines(3).tostring.replaceall("\"", ""),         lines(4).tostring.replaceall("\"", ""),         lines(5).tostring.replaceall("\"", "")     ) ) 

i know not doing date here not issue.


Comments