Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to read a CSV file into a DataFrame.
Apache Spark
df = spark.read.csv([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name.
Using incorrect method calls.
✗ Incorrect
The file path must be a string, so it needs quotes.
2fill in blank
mediumComplete the code to read a CSV file with header option enabled.
Apache Spark
df = spark.read.option("header", [1]).csv("data.csv")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean True without quotes.
Using capitalized "True" which Spark may not recognize.
✗ Incorrect
The option value must be a string, so use "true" with quotes.
3fill in blank
hardFix the error in the code to read a CSV file with delimiter set to comma.
Apache Spark
df = spark.read.option("delimiter", [1]).csv("data.csv")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Using wrong delimiter characters.
✗ Incorrect
The delimiter must be a string with a comma inside double quotes.
4fill in blank
hardFill both blanks to read a CSV file with header and inferSchema options enabled.
Apache Spark
df = spark.read.option("header", [1]).option("inferSchema", [2]).csv("data.csv")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean True without quotes.
Using capitalized "True" which Spark may not accept.
✗ Incorrect
Both options require string values "true" to enable them.
5fill in blank
hardFill all three blanks to read a CSV file with header, inferSchema, and delimiter options set.
Apache Spark
df = spark.read.option("header", [1]).option("inferSchema", [2]).option("delimiter", [3]).csv("data.csv")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using booleans instead of strings.
Using wrong delimiter characters.
✗ Incorrect
Enable header and inferSchema with "true" strings, and set delimiter to comma ",".