I've a data set with this fields:
Transaction_ID
Customer_ID
Department
Product_ID
And I'm trying to obtain a tuple with the products associated with each customer transaction. Like:
Transaction_1 -> Product_ID 1, Product_ID 2, Product_ID 3
Transaction_2 -> Product_ID 1, Product_ID 2, Product_ID 4
....
I've this code: But It not return the dataset as I want:
case class transactions (Transaction_ID: String, Customer_ID: String, Department: String, Product_ID: String)
def csvToMyClass(line: String) =
| {
| val split = line.split(',')
| transactions(split(0),split(1),split(2),split(3))
| }
val csv = sc.textFile("FILE").map(csvToMyClass)
csv.take(10)
csv.saveAsTextFile("PATH/output.csv")
How can I obtain the list of products associated group by Transaction_ID??