philHarasz
New Contributor III

After reading the suggested documentation, I tried using the "Parse nested XML (from_xml and schema_of_xml)". I used this code from the doc:

 

df = spark.createDataFrame([(8, xml_data)], ["number", "payload"])
schema = schema_of_xml(df.select("payload").limit(1).collect()[0][0])
parsed = df.withColumn("parsed", from_xml(col("payload"), schema))
parsed.printSchema()

 

and it worked great. But I don't understand what the number 8 signifies in that first argument to the createDataFrame command. I replaced it with different numbers while experimenting and it didn't seem to matter what number I put in there, so I left it as a 1. Once I saw the printed schema, I was then able to code a pyspark command to pull out the columns of a table. But I ended up with a one row dataframe where each column contained an array of all 100K values. So then I added an explode in front of each column, and that appeared to give me a dataframe that looked like a proper table. But when I tried to write it to a delta table, I got "The spark driver has stopped unexpectedly and is restarting. Your notebook will be automatically reattached.". So I removed the write and instead just put in this command, to see if I had a dataframe with any sensible data in it:

display(df.show(5))
I have now been waiting 53 minutes to see the first five rows of my dataframe. Nope. Still don't have a solution.