Skip to content

Instantly share code, notes, and snippets.

@gordinmitya
Created March 25, 2018 13:50
Show Gist options
  • Save gordinmitya/0058ea5b644a428192812e34091b861b to your computer and use it in GitHub Desktop.
Save gordinmitya/0058ea5b644a428192812e34091b861b to your computer and use it in GitHub Desktop.
val spark = org.apache.spark.sql.SparkSession.builder
.master("local")
.appName("Spark CSV Reader")
.getOrCreate
val df = spark.read
.format("csv")
.option("header", "false") //reading the headers
.option("mode", "DROPMALFORMED")
.schema(StructType(List(
StructField("polarity", IntegerType, nullable = false),
StructField("id", IntegerType, nullable = false),
StructField("date", StringType, nullable = false),
StructField("query", StringType, nullable = false),
StructField("user", StringType, nullable = false),
StructField("text", StringType, nullable = false)
)))
.load("/Users/mitya/Downloads/trainingandtestdata/testdata.manual.2009.06.14.csv")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment