twoentartian commented on a change in pull request #31827:
URL: https://github.com/apache/spark/pull/31827#discussion_r596028391



##########
File path: 
examples/src/main/scala/org/apache/spark/examples/sql/SQLDataSourceExample.scala
##########
@@ -246,6 +247,47 @@ object SQLDataSourceExample {
     // +---------------+----+
     // $example off:json_dataset$
   }
+  
+  private def runCsvDatasetExample(spark: SparkSession): Unit = {
+    // $example on:csv_dataset$
+    val path = "examples/src/main/resources/people.csv"
+
+    val df = spark.read.csv(path)
+    df.show()
+    // +------------------+
+    // |               _c0|
+    // +------------------+
+    // |      name;age;job|
+    // |Jorge;30;Developer|
+    // |  Bob;32;Developer|
+    // +------------------+
+
+    // Read a csv with delimiter, the default delimiter is ","
+    val df2 = spark.read.options(Map("delimiter"->";")).csv(path)
+    df2.show()
+    // +-----+---+---------+
+    // |  _c0|_c1|      _c2|
+    // +-----+---+---------+
+    // | name|age|      job|
+    // |Jorge| 30|Developer|
+    // |  Bob| 32|Developer|
+    // +-----+---+---------+
+
+    // Read a csv with delimiter and a header
+    val df3 = 
spark.read.options(Map("delimiter"->";","header"->"true")).csv(path)

Review comment:
       I add `.option()` and `.options()` to both Scala and Python examples.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to