0
0
Apache Sparkdata~10 mins

Reading CSV files with options in Apache Spark - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Acsv.read("data.csv")
B"data.csv"
Cread.csv("data.csv")
Ddata.csv
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around the file name.
Using incorrect method calls.
2fill in blank
medium

Complete 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'
A"true"
Btrue
C"True"
DTrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean True without quotes.
Using capitalized "True" which Spark may not recognize.
3fill in blank
hard

Fix 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'
A";"
B';'
C","
D'\t'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes instead of double quotes.
Using wrong delimiter characters.
4fill in blank
hard

Fill 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'
A"True"
B"False"
C"true"
D"false"
Attempts:
3 left
💡 Hint
Common Mistakes
Using boolean True without quotes.
Using capitalized "True" which Spark may not accept.
5fill in blank
hard

Fill 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'
A"True"
B"False"
C","
D";"
Attempts:
3 left
💡 Hint
Common Mistakes
Using booleans instead of strings.
Using wrong delimiter characters.