def list_to_csv_str(x):
    """Given a list of strings, returns a properly-csv-formatted string."""
output = io.StringIO('')
csv.writer(output).writerow(x)
return output.getvalue().strip()
rdd = rdd.map(list_to_csv_str)
rdd.saveAsTextFile('output_directory')
How to write the resulting RDD to a csv file in Spark python