Spark - Regex - Splitting Columns

#1

Hello,

I am doing a Spark question which involves the following line of code to apply regex of splitting columns:

val cData = sc.textFile("/public/crime/csv").map(r => { var d = r.split(",(?=(?:[^"] “[^”] “) [^"] $)”, -1); (d(0),d(5),d(7))} )

However when I run this particular line of code on the lab, I generate the following error:

:1: error: ‘)’ expected but ‘]’ found.
val cData = sc.textFile("/public/crime/csv").map(r => { var d = r.split(",(?=(?:[^"]"[^"]")[^"]$)", -1); (d(0),d(5),d(7))} )
^
:1: error: unclosed string literal
val cData = sc.textFile("/public/crime/csv").map(r => { var d = r.split(",(?=(?:[^"]"[^"]")[^"]$)", -1); (d(0),d(5),d(7))} )

Can someone help me on this issue please?

Many thanks,
Patrick

0 Likes