I am reading in a csv using pandas chunks functionality. It works, except for I am not able to retain headers. Is there a way/option to do this? here is sample code:
import pyspark
import pandas as pd
sc = pyspark.SparkContext(appName="myAppName")
spark_rdd = sc.emptyRDD()
# filename: csv file
chunks = pd.read_csv(filename, chunksize=10000)
for chunk in chunks:
spark_rdd += sc.parallelize(chunk.values.tolist())
#print(chunk.head())
#print(spark_rdd.toDF().show())
#break
spark_df = spark_rdd.toDF()
spark_df.show()