I have a flat file delimited by | (pipe), without quote character. Sample data looks as following:
SOME_NUMBER|SOME_MULTILINE_STRING|SOME_STRING
23|multiline
text1|text1
24|multi
mulitline
text2|text2
25|text3|text4
What I'm trying to do is to load it into a dataframe to look something like this:
| SOME_NUMBER | SOME_MULTILINE_STRING | SOME_STRING |
|---|---|---|
| 23 | multiline text1 |
text1 |
| 24 | multi mulitline text2 |
text2 |
| 25 | text3 | text4 |
I tried to specify multiLine option with no luck. Regardless of it being set to True or False, the output doesn't change. I suppose what I'm trying to achieve there is to specify that I'm expecting multi-line data, and every record has the same number of columns specified in the schema.
df_file = spark.read.csv(filePath, \
sep="|", \
header=True, \
enforceSchema=True, \
schema=df_table.schema, \ # I need to explicitly specify the schema
quote='', \
multiLine=True)