{"id":1120,"date":"2013-03-13T19:53:58","date_gmt":"2013-03-13T18:53:58","guid":{"rendered":"http:\/\/denbeke.be\/blog\/?page_id=1120"},"modified":"2013-03-13T19:53:58","modified_gmt":"2013-03-13T18:53:58","slug":"itunes-library-parser-tablegenerator","status":"publish","type":"page","link":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/","title":{"rendered":"iTunes Library Parser &#8211; TableGenerator"},"content":{"rendered":"<pre><code data-language=\"python\">class TableGenerator:\r\n'''Class for generating a HTML file with a list of albums. Input comes from iTune Library XML file'''\r\n\r\ndef __init__(self, input_file, output_file):\r\n    '''Constructor'''\r\n\r\n    #html header\r\n    self.htmlHeader = \"&lt;!DOCTYPE html&gt;&lt;html lang=\\\"en\\\"&gt;&lt;head&gt;&lt;meta charset=\\\"utf-8\\\"&gt;&lt;title&gt;iTunes Albums&lt;\/title&gt;&lt;!--[if lt IE 9]&gt;&lt;script src=\\\"http:\/\/html5shim.googlecode.com\/svn\/trunk\/html5.js\\\"&gt;&lt;\/script&gt;&lt;![endif]--&gt;&lt;\/head&gt;&lt;body&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Album&lt;\/th&gt;&lt;th&gt;Artiest&lt;\/th&gt;&lt;th&gt;Year&lt;\/th&gt;&lt;\/tr&gt;\"\r\n\r\n    #empty content, content is created with generateHTMLContent()\r\n    self.htmlContent = \"\"\r\n\r\n    #html footer\r\n    self.htmlFooter = \"&lt;\/tbody&gt;&lt;\/table&gt;&lt;\/body&gt;&lt;\/html&gt;\"\r\n\r\n    self.albumList = AlbumListGenerator(input_file)\r\n    self.outputFile = output_file\r\n    self.albumList.generateList()\r\n\r\ndef generateHTMLContent(self):\r\n    '''Generates the string containing the albums formatted in HTML'''\r\n\r\n    #Loop through all albuls\r\n    for album in self.albumList.getList():\r\n        line = \"\" #reset line\r\n        line += \"&lt;tr&gt;&lt;td&gt;\"+album.getAlbum()+\"&lt;\/td&gt;&lt;td&gt;\"+album.getArtist()+\"&lt;\/td&gt;&lt;td&gt;\"+album.getYear()+\"&lt;\/td&gt;&lt;\/tr&gt;\" #format line           \r\n        self.htmlContent += line #Add line to content\r\n\r\ndef writeFile(self):\r\n    '''Writes the html code to a file'''\r\n    self.generateHTMLContent()\r\n    file = open(outputFile, 'w')\r\n    file.write(self.htmlHeader+self.htmlContent+self.htmlFooter)\r\n    file.close()<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>class TableGenerator: &#8221;&#8217;Class for generating a HTML file with a list of albums. Input comes from iTune Library XML file&#8221;&#8217; def __init__(self, input_file, output_file): &#8221;&#8217;Constructor&#8221;&#8217; #html header self.htmlHeader = &#8220;&lt;!DOCTYPE html&gt;&lt;html lang=\\&#8221;en\\&#8221;&gt;&lt;head&gt;&lt;meta charset=\\&#8221;utf-8\\&#8221;&gt;&lt;title&gt;iTunes Albums&lt;\/title&gt;&lt;!&#8211;[if lt IE 9]&gt;&lt;script src=\\&#8221;http:\/\/html5shim.googlecode.com\/svn\/trunk\/html5.js\\&#8221;&gt;&lt;\/script&gt;&lt;![endif]&#8211;&gt;&lt;\/head&gt;&lt;body&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Album&lt;\/th&gt;&lt;th&gt;Artiest&lt;\/th&gt;&lt;th&gt;Year&lt;\/th&gt;&lt;\/tr&gt;&#8221; #empty content, content is created with generateHTMLContent() self.htmlContent = &#8220;&#8221; #html footer self.htmlFooter = &#8220;&lt;\/tbody&gt;&lt;\/table&gt;&lt;\/body&gt;&lt;\/html&gt;&#8221; self.albumList = [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":1102,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"class_list":["post-1120","page","type-page","status-publish","hentry","entry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>iTunes Library Parser - TableGenerator &#8211; DenBeke<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"iTunes Library Parser - TableGenerator &#8211; DenBeke\" \/>\n<meta property=\"og:description\" content=\"class TableGenerator: &#039;&#039;&#039;Class for generating a HTML file with a list of albums. Input comes from iTune Library XML file&#039;&#039;&#039; def __init__(self, input_file, output_file): &#039;&#039;&#039;Constructor&#039;&#039;&#039; #html header self.htmlHeader = &quot;&lt;!DOCTYPE html&gt;&lt;html lang=&quot;en&quot;&gt;&lt;head&gt;&lt;meta charset=&quot;utf-8&quot;&gt;&lt;title&gt;iTunes Albums&lt;\/title&gt;&lt;!--[if lt IE 9]&gt;&lt;script src=&quot;http:\/\/html5shim.googlecode.com\/svn\/trunk\/html5.js&quot;&gt;&lt;\/script&gt;&lt;![endif]--&gt;&lt;\/head&gt;&lt;body&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Album&lt;\/th&gt;&lt;th&gt;Artiest&lt;\/th&gt;&lt;th&gt;Year&lt;\/th&gt;&lt;\/tr&gt;&quot; #empty content, content is created with generateHTMLContent() self.htmlContent = &quot;&quot; #html footer self.htmlFooter = &quot;&lt;\/tbody&gt;&lt;\/table&gt;&lt;\/body&gt;&lt;\/html&gt;&quot; self.albumList = [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/\" \/>\n<meta property=\"og:site_name\" content=\"DenBeke\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@MthsBk\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-tablegenerator\\\/\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-tablegenerator\\\/\",\"name\":\"iTunes Library Parser - TableGenerator &#8211; DenBeke\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\"},\"datePublished\":\"2013-03-13T18:53:58+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-tablegenerator\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-tablegenerator\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/itunes-library-parser-tablegenerator\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"iTunes Library Parser\",\"item\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/itunes-library-parser\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"iTunes Library Parser &#8211; TableGenerator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/\",\"name\":\"DenBeke\",\"description\":\"Mathias Beke\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/denbeke.be\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"iTunes Library Parser - TableGenerator &#8211; DenBeke","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/","og_locale":"en_US","og_type":"article","og_title":"iTunes Library Parser - TableGenerator &#8211; DenBeke","og_description":"class TableGenerator: '''Class for generating a HTML file with a list of albums. Input comes from iTune Library XML file''' def __init__(self, input_file, output_file): '''Constructor''' #html header self.htmlHeader = \"&lt;!DOCTYPE html&gt;&lt;html lang=\"en\"&gt;&lt;head&gt;&lt;meta charset=\"utf-8\"&gt;&lt;title&gt;iTunes Albums&lt;\/title&gt;&lt;!--[if lt IE 9]&gt;&lt;script src=\"http:\/\/html5shim.googlecode.com\/svn\/trunk\/html5.js\"&gt;&lt;\/script&gt;&lt;![endif]--&gt;&lt;\/head&gt;&lt;body&gt;&lt;table&gt;&lt;tbody&gt;&lt;tr&gt;&lt;th&gt;Album&lt;\/th&gt;&lt;th&gt;Artiest&lt;\/th&gt;&lt;th&gt;Year&lt;\/th&gt;&lt;\/tr&gt;\" #empty content, content is created with generateHTMLContent() self.htmlContent = \"\" #html footer self.htmlFooter = \"&lt;\/tbody&gt;&lt;\/table&gt;&lt;\/body&gt;&lt;\/html&gt;\" self.albumList = [&hellip;]","og_url":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/","og_site_name":"DenBeke","twitter_card":"summary_large_image","twitter_site":"@MthsBk","twitter_misc":{"Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/","url":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/","name":"iTunes Library Parser - TableGenerator &#8211; DenBeke","isPartOf":{"@id":"https:\/\/denbeke.be\/blog\/#website"},"datePublished":"2013-03-13T18:53:58+00:00","breadcrumb":{"@id":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/itunes-library-parser-tablegenerator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/denbeke.be\/blog\/"},{"@type":"ListItem","position":2,"name":"iTunes Library Parser","item":"https:\/\/denbeke.be\/blog\/itunes-library-parser\/"},{"@type":"ListItem","position":3,"name":"iTunes Library Parser &#8211; TableGenerator"}]},{"@type":"WebSite","@id":"https:\/\/denbeke.be\/blog\/#website","url":"https:\/\/denbeke.be\/blog\/","name":"DenBeke","description":"Mathias Beke","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/denbeke.be\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/comments?post=1120"}],"version-history":[{"count":1,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1120\/revisions"}],"predecessor-version":[{"id":1121,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1120\/revisions\/1121"}],"up":[{"embeddable":true,"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/pages\/1102"}],"wp:attachment":[{"href":"https:\/\/denbeke.be\/blog\/wp-json\/wp\/v2\/media?parent=1120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}