Spark XML - Use XMLs from Excel

Viewed 165

I have an Excel sheet where one column has XMLs (each row is a different xml). I am trying to use Pyspark and spark-xml to parse these, by doing df = spark.read.format('xml').options(rowTag = 'book').load(___).

The load works fine when you specify an xml file, but is it possible to read in the Excel sheet and loop in those xmls to be parsed without having to convert each one to its own xml file?

1 Answers

You need to first read the Excel file as a Spark DataFrame. Then you can further parse a String column containing XML with the from_xml function. That gives a new column with the parsed data from the XML column.

Related