I am using Spark 1.3.1 (PySpark) and I have generated a table using a SQL query. I now have an object that is a DataFrame. I want to export this DataFrame
DataFrame
How about this (in you don't want an one liner) ?
for row in df.collect(): d = row.asDict() s = "%d\t%s\t%s\n" % (d["int_column"], d["string_column"], d["string_column"]) f.write(s)
f is a opened file descriptor. Also the separator is a TAB char, but it's easy to change to whatever you want.