'Writing file into hdfs from spark rdd

I am trying to write the elements of sparkrdd into hdfs filesystem. Particular RDD is of type RDD[List(String)]

So in the file am getting the output like List(6, 125, 6988, 2021-10-01, ST, LENS)

How could I save this as shown below? 6, 125, 6988, 2021-10-01, ST, LENS



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source