to read csv in matrix format in spark code example Example: read csv in spark df = spark. read . format("csv") . option("header", "true")