2017-04-18 62 views

回答

1

你可以嘗試設置mode"DROPMALFORMED"爲:

val df = sqlContext.read.format("com.databricks.spark.csv").option("mode", "DROPMALFORMED")... 

Python

df = sqlContext.read.format('com.databricks.spark.csv').options(mode = "DROPMALFORMED")... 

其中根據documentation

"...drops lines which have fewer or more tokens than expected."

+0

現在我得到這個錯誤: va lue選項不是org.apache.spark.sql.DataFrame的成員 –

+1

我認爲上面使用了Python語法。對於Scala,請使用spark.read.option(「mode」,「DROPMALFORMED」)。csv(path) –