spark-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anbutech <anbutec...@outlook.com>
Subject Spark 2.4 scala 2.12 Regular Expressions Approach
Date Mon, 15 Jul 2019 15:57:43 GMT
Hi All,

Could you please help me to fix the below issue using spark 2.4 , scala 2.12 

How do we extract's the multiple values in the given file name pattern using 
spark/scala regular expression.please 
give me some idea on the below approach.

object Driver {

private val filePattern =
xyzabc_source2target_adver_1stvalue_([a-zA-Z0-9]+)_2ndvalue_([a-zA-Z0-9]+)_3rdvalue_([a-zA-Z0-9]+)_4thvalue_
([a-zA-Z0-9]+)_5thvalue_([a-zA-Z0-9]+)_6thvalue_([a-zA-Z0-9]+)_7thvalue_([a-zA-Z0-9]+)".r

How to get all 7 values like "([a-zA-Z0-9]+)"  from above regular expression
pattern using spark scala 
and assigned it to the below processing method  , i.e. case class schema
fields

def processing(x:Dataset[someData]){

x.map{
e =>

caseClassSchema(
Field1 = 1stvalue
Field2 = 2ndvalue
Field3 = 3rdvalue
Field4 = 4thvalue
Field5 = 5thvalue
Field6 = 6thvalue
Field7 = 7thvalue
)
}
}


Thanks
Anbu




--
Sent from: http://apache-spark-user-list.1001560.n3.nabble.com/

---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscribe@spark.apache.org


Mime
View raw message