A data scientist wants each record in the DataFrame to contain:
The first attempt at the code does read the text files but each record contains a single line. This code is shown below:

The entire contents of a file
The full file path
The issue: reading line-by-line rather than full text per file.
Code:
corpus = spark.read.text("/datasets/raw_txt/*") \
.select('*', '_metadata.file_path')
Which change will ensure one record per file?
Options:
To read each file as a single record, use:
spark.read.text(path, wholetext=True)
This ensures that Spark reads the entire file contents into one row.
Andra
1 month agoFloyd
1 month agoMyrtie
1 month agoTashia
2 months agoLong
2 months agoLina
2 months agoLawrence
4 months agoDorethea
4 months agoMiesha
4 months agoHalina
5 months agoTequila
5 months agoRoselle
5 months ago