I have a .dat file delimited by \u0001. It should look like so
+---+---+---+
|A |B |C |
+---+---+---+
|1 |2,3|4 |
+---+---+---+
|5 |6 |7 |
+---+---+---+
But the file I get has a lot of spaces between fields of a few rows
A\u0001B\u0001C
1\u0001"2,3" \u00014
5\u00016\u00017
In the second row above, there are 79 spaces between two columns. Now when I read the file in Spark
val df = spark.read.format("csv").option("header", "true").option("delimiter", "\u0001").load("path")
df.show(false)
+---+-----------------------------------------------------------------------------------+----+
|A |B |C |
+---+-----------------------------------------------------------------------------------+----+
|1 |2,3 4|null|
+---+-----------------------------------------------------------------------------------+----+
|5 |6 |7 |
+---+-----------------------------------------------------------------------------------+----+
Is there a way to fix this without changing the input file?