Complete the code to read a CSV file into a DataFrame.
df = spark.read.format([1]).load("data/employees.csv")
The format method specifies the file type. For CSV files, use "csv".
Complete the code to read a JSON file into a DataFrame.
df = spark.read.[1]("data/employees.json")
read.csv() or read.parquet() for JSON files.read.text() which reads raw text lines.The read.json() method reads JSON files directly into a DataFrame.
Fix the error in the code to read a Parquet file into a DataFrame.
df = spark.read.format("parquet").[1]("data/employees.parquet")
read() instead of load() after format().json() or csv() methods for Parquet files.The load() method loads the file after specifying the format.
Fill both blanks to read a CSV file with header and infer schema options.
df = spark.read.format("csv").option([1], "true").option([2], "true").load("data/employees.csv")
delimiter or path options incorrectly.header or inferSchema to "true".To read CSV with headers and infer data types, use options header and inferSchema set to "true".
Fill both blanks to create a DataFrame from JSON with multiLine option enabled.
df = spark.read.format([1]).option([2], "true").load("data/employees_multiline.json")
csv or parquet format for JSON files.To read multiline JSON files, specify format as "json" and set option multiLine to "true".
