I am new in Spark/Scala. I know how to load CSV files:
sqlContext.read.format(\"csv\")
and how to read text streams and file streams:
Here you go:
val ssc = new StreamingContext(sparkConf, Seconds(5))
// Create the FileInputDStream on the directory
val lines = ssc.textFileStream("file:///C:/foo/bar")
lines.foreachRDD(rdd => {
if (!rdd.isEmpty()) {
println("RDD row count: " + rdd.count())
// Now you can convert this RDD to DataFrame/DataSet and perform business logic.
}
}
})
ssc.start()
ssc.awaitTermination()
}
You can stream your Csv file easily by using spark 2.2 structured streaming.
You can refer here