I have a csv data in which I've escaped existing backslash characters using another backslash:
year,content
2021,"\\"foo\\",bar"
I'd like to read it using spark and display the data. The expected data on the dataframe:
+----------+--------------+
| year | content |
+----------+--------------+
| 2021 | \"foo\",bar |
+----------+--------------+
But when I ran this:
schema = StructType(
[
StructField("year", IntegerType(), False),
StructField("content", StringType(), False),
]
)
df = (
spark.read.csv(
f"s3://path/to/csv",
schema=schema,
header=True
)
)
df.show(20,False)
I'm getting this:
+----------+--------------+
| year | content |
+----------+--------------+
| 2021 | "\"foo\\" |
+----------+--------------+
Any idea how to handle this properly?