Get CSV to Spark dataframe

前端 未结 9 1203
忘了有多久
忘了有多久 2020-12-05 14:45

I\'m using python on Spark and would like to get a csv into a dataframe.

The documentation for Spark SQL strangely does not provide explanations for CSV as a source.

9条回答
  •  有刺的猬
    2020-12-05 14:53

    for Pyspark, assuming that the first row of the csv file contains a header

    spark = SparkSession.builder.appName('chosenName').getOrCreate()
    df=spark.read.csv('fileNameWithPath', mode="DROPMALFORMED",inferSchema=True, header = True)
    

提交回复
热议问题