Read a file in spark

PHOTO EMBED

Thu Jun 26 2025 07:58:40 GMT+0000 (Coordinated Universal Time)

Saved by @Saravana_Kumar #python

def spark_read_file(file_path,file_format,schema=None):
    input_data = (
        spark.read.format(file_format)
        # .option("basePath", base_path)
        .option("header", "true")
        .schema(schema)
        .load(f"{file_path}*")
    )
    return input_data
content_copyCOPY