{"id":124155,"date":"2022-04-22T18:22:47","date_gmt":"2022-04-22T18:22:47","guid":{"rendered":"https:\/\/blog.finxter.com\/?p=312946"},"modified":"2022-04-22T18:22:47","modified_gmt":"2022-04-22T18:22:47","slug":"how-to-read-an-xls-file-in-python","status":"publish","type":"post","link":"https:\/\/sickgaming.net\/blog\/2022\/04\/22\/how-to-read-an-xls-file-in-python\/","title":{"rendered":"How to Read an XLS File in Python?"},"content":{"rendered":"<h2 class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">Problem Formulation and Solution Overview<\/h2>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">In this article, you&#8217;ll learn how to read an XML file and format the output in Python. <\/p>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">To make it more fun, we have the following running scenario:<\/p>\n<p><em>Arman, a Music Appreciation student at the <a href=\"https:\/\/www.rcmusic.com\/learning\/oscar-peterson-school-of-music\/music-appreciation\" data-type=\"URL\" data-id=\"https:\/\/www.rcmusic.com\/learning\/oscar-peterson-school-of-music\/music-appreciation\" target=\"_blank\" rel=\"noreferrer noopener\">Royal Conservatory of Music<\/a>, has been given course materials in an XML file format. Arman needs to purchase these books immediately. He&#8217;s into music, not computers. He needs you to format the output into a readable format.<\/em><\/p>\n<p><em>Navigate to the Appendix Data<\/em> section<em> and download the XML file to follow along. Then, move this file to the current working directory.<\/em><\/p>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4ac.png\" alt=\"\ud83d\udcac\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/> <strong>Question<\/strong>: How would we read in ax XML file and format the output?<\/p>\n<p>We can accomplish this task by one of the following options:<\/p>\n<ul>\n<li><strong>Method 1<\/strong>: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/installing-beautiful-soup\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/installing-beautiful-soup\/\" target=\"_blank\"><em>Beautiful Soup<\/em><\/a><\/li>\n<li><strong>Method 2<\/strong>: Use <a href=\"https:\/\/docs.python.org\/3\/library\/xml.etree.elementtree.html\" data-type=\"URL\" data-id=\"https:\/\/docs.python.org\/3\/library\/xml.etree.elementtree.html\">XML eTree<\/a><\/li>\n<li><strong>Method 3<\/strong>: Use <a rel=\"noreferrer noopener\" href=\"https:\/\/docs.python.org\/3\/library\/xml.dom.minidom.html\" data-type=\"URL\" data-id=\"https:\/\/docs.python.org\/3\/library\/xml.dom.minidom.html\" target=\"_blank\">Minidom<\/a><\/li>\n<li><strong>Method 4<\/strong>: Use <a href=\"https:\/\/blog.finxter.com\/category\/pandas-library\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/category\/pandas-library\/\" target=\"_blank\" rel=\"noreferrer noopener\">Pandas<\/a><\/li>\n<\/ul>\n<hr class=\"wp-block-separator\"\/>\n<p class=\"wp-embed-aspect-16-9 wp-has-aspect-ratio\">Before any data manipulation can occur, two (2) new libraries will require installation.<\/p>\n<ul>\n<li>The <em><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a> <\/em>library enables access to\/from a DataFrame.<\/li>\n<li>The <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/installing-beautiful-soup\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/installing-beautiful-soup\/\" target=\"_blank\"><em>Beautiful Soup<\/em><\/a> library enables the parsing of XML and HTML files.<\/li>\n<\/ul>\n<p>To install these libraries, navigate to an <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/best-python-ide\/\" data-type=\"post\" data-id=\"8106\" target=\"_blank\">IDE<\/a> terminal. At the command prompt (<code>$<\/code>), execute the code below. For the terminal used in this example, the command prompt is a dollar sign (<code>$<\/code>). Your terminal prompt may be different.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ pip install pandas<\/pre>\n<p>Hit the <code>&lt;Enter&gt;<\/code> key on the keyboard to start the installation process.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">$ pip install bs4<\/pre>\n<p>Hit the <code>&lt;Enter&gt;<\/code> key on the keyboard to start the installation process.<\/p>\n<p>If the installations were successful, a message displays in the terminal indicating the same.<\/p>\n<hr class=\"wp-block-separator\"\/>\n<p>Feel free to view the PyCharm installation guide for the required libraries.<\/p>\n<ul>\n<li><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/how-to-install-a-library-on-pycharm\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/how-to-install-a-library-on-pycharm\/\" target=\"_blank\">How to install<\/a><a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/how-to-install-pandas-in-python\/\" target=\"_blank\"> Pandas on PyCharm<\/a><\/li>\n<li><a href=\"https:\/\/blog.finxter.com\/how-to-install-beautifulsoup-on-pycharm\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/how-to-install-beautifulsoup-on-pycharm\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to install Beautiful Soup on PyCharm<\/a><\/li>\n<\/ul>\n<hr class=\"wp-block-separator\"\/>\n<p id=\"block-3b5c9c73-276c-4b84-a1bc-d5ba1de38d56\">Add the following code to the top of each code snippet. This snippet will allow the code in this article to run error-free.<\/p>\n<pre class=\"EnlighterJSRAW wp-embed-aspect-16-9 wp-has-aspect-ratio\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd from bs4 import BeautifulSoup\nimport xml.etree.ElementTree as ET\nimport base64, xml.dom.minidom\nfrom xml.dom.minidom import Node<\/pre>\n<p class=\"has-global-color-8-background-color has-background\"><img decoding=\"async\" src=\"https:\/\/s.w.org\/images\/core\/emoji\/13.1.0\/72x72\/1f4a1.png\" alt=\"\ud83d\udca1\" class=\"wp-smiley\" style=\"height: 1em; max-height: 1em;\" \/>&nbsp;<strong>Note<\/strong>: The additional libraries indicated above do not require installation as they come built-in to Python.<\/p>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 1: Use Beautiful Soup<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">A clean, compact way to read an XML file is to use Python&#8217;s <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/installing-beautiful-soup\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/installing-beautiful-soup\/\" target=\"_blank\">Beautiful Soup<\/a> library. A &#8220;go-to&#8221; tool for web scraping and XML data extraction.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"1\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">all_books = BeautifulSoup(open('books.xml'), 'xml')\npretty_xml = all_books.prettify()\nprint(pretty_xml)<\/pre>\n<ul>\n<li>The <em>books.xml<\/em> file is read and parsed using Beautiful Soup&#8217;s <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/parsing-xml-using-beautifulsoup-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/parsing-xml-using-beautifulsoup-in-python\/\" target=\"_blank\">XML parser<\/a>. The results are saved to <code>all_books<\/code>.<\/li>\n<li>Next, Beautiful Soup&#8217;s <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/parsing-xml-using-beautifulsoup-in-python\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/parsing-xml-using-beautifulsoup-in-python\/\" target=\"_blank\"><code>prettify()<\/code><\/a> method is used to improve the appearance of the output.<\/li>\n<li>Finally, the formatted output is sent to the terminal.<\/li>\n<\/ul>\n<p><strong>Output (snippet)<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><code>&lt;?xml version=\"1.0\"?><br \/>&lt;catalog>\u00a0 \u00a0<br \/> &lt;book>\u00a0 \u00a0 \u00a0 <br \/> &lt;isbn>978-0393050714&lt;\/isbn><br \/>\u00a0 \u00a0 \u00a0 &lt;title>Johann Sebastian Bach&lt;\/title><br \/>\u00a0 \u00a0 \u00a0 &lt;price>$5.99&lt;\/price><br \/>\u00a0 \u00a0&lt;\/book><br \/> ......<br \/>&lt;\/catalog><\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 2: Use XML eTree<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">The ElementTree library is built-in to Python and contains functions to read and parse XML and XML-like data structures. The hierarchical data format is based on a tree structure: a <em>root <\/em>representing the tree and <em>elements <\/em>representing the nodes. <\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"1\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">all_books = ET.parse('books.xml').getroot() for b in all_books.findall('book'): print (\"{:&lt;20} {:&lt;30} {:&lt;30}\".format(b.find('isbn').text, b.find('title').text, b.find('price').text))<\/pre>\n<ul>\n<li>The <em>books.xml<\/em> file is read in and parsed using the <code><a rel=\"noreferrer noopener\" href=\"https:\/\/docs.python.org\/3\/library\/xml.etree.elementtree.html\" data-type=\"URL\" data-id=\"https:\/\/docs.python.org\/3\/library\/xml.etree.elementtree.html\" target=\"_blank\">eTree parse()<\/a><\/code> function. The results are saved to <code>all_books<\/code>.<\/li>\n<li>Next, a <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-loops\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-loops\/\" target=\"_blank\">For<\/a> loop is instantiated. It traverses through each book in <code>all_books<\/code>.\n<ul>\n<li>Each book&#8217;s details are formatted into columns and output to the terminal.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Output (snippet)<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td>978-0393050714<\/td>\n<td>Johann Sebastian Bach<\/td>\n<td>$5.99<\/td>\n<\/tr>\n<tr>\n<td>978-1721260522<\/td>\n<td>Ludwig van Beethoven<\/td>\n<td>$9.99<\/td>\n<\/tr>\n<tr>\n<td>978-0679745822<\/td>\n<td>Johannes Brahms<\/td>\n<td>$7.99<\/td>\n<\/tr>\n<tr>\n<td>979-8653086533<\/td>\n<td>Frederic Chopin<\/td>\n<td>$7.99<\/td>\n<\/tr>\n<tr>\n<td>978-1580469036<\/td>\n<td>Claude Debussy<\/td>\n<td>$13.99<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 3: Use minidom<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">Minidom is a smaller version of DOM and comes with an API similar to other programming languages. However, feedback indicates this method is slow and a memory hogger. <\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"5\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">with open(\"books.xml\",'r') as fp: data = fp.read() i = 0\nall_books = xml.dom.minidom.parseString(data)\nfor book in all_books.getElementsByTagName('book'): isbn = all_books.getElementsByTagName('isbn')[i].firstChild.nodeValue title = all_books.getElementsByTagName('title')[i].firstChild.nodeValue price = all_books.getElementsByTagName('price')[i].firstChild.nodeValue print (\"{:&lt;20} {:&lt;25} {:&lt;20}\".format(isbn, title, price)) i +=1<\/pre>\n<ul>\n<li>The <em>books.xml<\/em> file is opened, and a file object, <code>fp<\/code> is created.\n<ul>\n<li>The contents of this file are read in and saved to <code>data<\/code>.<\/li>\n<\/ul>\n<\/li>\n<li>A counter variable <code>i<\/code> is created to loop through <code>all_books<\/code> and is assigned the value 0.<\/li>\n<li>Then <code>data<\/code> is read and parsed. The results save to <code>all_books<\/code>.<\/li>\n<li>A <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/python-loops\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/python-loops\/\" target=\"_blank\">For<\/a> loop is instantiated. It traverses through each book in <code>all_books<\/code>.\n<ul>\n<li>Four (4) variables are used to locate and save the appropriate values.<\/li>\n<li>They are formatted and output to the terminal in columns.<\/li>\n<li>The counter variable is increased by one (1).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>Output (snippet)<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td>978-0393050714<\/td>\n<td>Johann Sebastian Bach<\/td>\n<td>$5.99<\/td>\n<\/tr>\n<tr>\n<td>978-1721260522<\/td>\n<td>Ludwig van Beethoven<\/td>\n<td>$9.99<\/td>\n<\/tr>\n<tr>\n<td>978-0679745822<\/td>\n<td>Johannes Brahms<\/td>\n<td>$7.99<\/td>\n<\/tr>\n<tr>\n<td>979-8653086533<\/td>\n<td>Frederic Chopin<\/td>\n<td>$7.99<\/td>\n<\/tr>\n<tr>\n<td>978-1580469036<\/td>\n<td>Claude Debussy<\/td>\n<td>$13.99<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Method 4: Use Pandas read_xml()<\/h2>\n<p class=\"has-global-color-8-background-color has-background\">The <a rel=\"noreferrer noopener\" href=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" data-type=\"URL\" data-id=\"https:\/\/blog.finxter.com\/pandas-quickstart\/\" target=\"_blank\">Pandas<\/a> library has an option to read in an XML file and convert it to a DataFrame in one easy step.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"1\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">df = pd.read_xml('books.xml')\nprint(df)<\/pre>\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\">\n<div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"Reading and writing XML with Pandas\" width=\"780\" height=\"439\" src=\"https:\/\/www.youtube.com\/embed\/zIzH5GfHHD8?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture\" allowfullscreen><\/iframe>\n<\/div>\n<\/figure>\n<ul>\n<li>The <em>books.xml<\/em> file is read in and saved to the DataFrame <code>df<\/code>.<\/li>\n<li>The output automatically formats into columns (including a header row) and is output to the terminal.<\/li>\n<\/ul>\n<p><strong>Output (snippet)<\/strong><\/p>\n<figure class=\"wp-block-table is-style-stripes\">\n<table>\n<tbody>\n<tr>\n<td><\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">isbn<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">title<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">price<\/td>\n<\/tr>\n<tr>\n<td>0<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">978-0393050714<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">Johann Sebastian Bach<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">$5.99<\/td>\n<\/tr>\n<tr>\n<td>1<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">978-1721260522<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">Ludwig van Beethoven<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">$9.99<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">978-0679745822<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">Johannes Brahms<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">$7.99<\/td>\n<\/tr>\n<tr>\n<td>3<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">979-8653086533<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">Frederic Chopin<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">$7.99<\/td>\n<\/tr>\n<tr>\n<td>4<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">978-1580469036<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">Claude Debussy<\/td>\n<td class=\"has-text-align-right\" data-align=\"right\">$13.99<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/figure>\n<hr class=\"wp-block-separator\"\/>\n<h2>Appendix Data<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;?xml version=\"1.0\"?>\n&lt;catalog>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-0393050714&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Johann Sebastian Bach&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$5.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-1721260522&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Ludwig van Beethoven&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$9.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-0679745822&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Johannes Brahms&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$7.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>979-8653086533&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Frederic Chopin&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$7.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-1580469036&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Claude Debussy&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$13.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-0520043176&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Joseph Haydn&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$25.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-1981659968&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Wolfgang Amadeus Mozart&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$8.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-1482379990&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Franz Schubert&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$26.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-0486257488&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Robert Schumann&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$14.99&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n\u00a0 \u00a0&lt;book>\n\u00a0 \u00a0 \u00a0 &lt;isbn>978-0486442723&lt;\/isbn>\n\u00a0 \u00a0 \u00a0 &lt;title>Peter Tchaikovsky&lt;\/title>\n\u00a0 \u00a0 \u00a0 &lt;price>$12.95&lt;\/price>\n\u00a0 \u00a0&lt;\/book>\n&lt;\/catalog><\/pre>\n<hr class=\"wp-block-separator\"\/>\n<h2>Summary<\/h2>\n<p>After reviewing the above methods in conjunction with Arman&#8217;s requirements, we decide that Method 4 best meets his needs.<\/p>\n<p>Problem Solved! Happy Coding!<\/p>\n<hr class=\"wp-block-separator\"\/>\n","protected":false},"excerpt":{"rendered":"<p>Problem Formulation and Solution Overview In this article, you&#8217;ll learn how to read an XML file and format the output in Python. To make it more fun, we have the following running scenario: Arman, a Music Appreciation student at the Royal Conservatory of Music, has been given course materials in an XML file format. Arman [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[857],"tags":[73,468,528],"class_list":["post-124155","post","type-post","status-publish","format-standard","hentry","category-python-tut","tag-programming","tag-python","tag-tutorial"],"_links":{"self":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124155","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/comments?post=124155"}],"version-history":[{"count":0,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/posts\/124155\/revisions"}],"wp:attachment":[{"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/media?parent=124155"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/categories?post=124155"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/sickgaming.net\/blog\/wp-json\/wp\/v2\/tags?post=124155"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}