{"id":393,"date":"2020-08-26T14:42:49","date_gmt":"2020-08-26T14:42:49","guid":{"rendered":"https:\/\/aaidm.buas.nl\/?page_id=393"},"modified":"2020-08-26T15:22:33","modified_gmt":"2020-08-26T15:22:33","slug":"pr1-preparation-for-week-7-reading-a-file","status":"publish","type":"page","link":"https:\/\/aaidm.buas.nl\/?page_id=393","title":{"rendered":"PR1 &#8211; Preparation for Week 7 &#8211; Reading a file"},"content":{"rendered":"\n<div class=\"wp-block-group\"><div class=\"wp-block-group__inner-container is-layout-flow wp-block-group-is-layout-flow\">\n<figure class=\"wp-block-table\"><table><tbody><tr><td>uthor:<\/td><td>Carlos Santos<\/td><\/tr><tr><td>Learning Line:<\/td><td>Programming<\/td><\/tr><tr><td>Course:<\/td><td>PR1: Introduction to Programming<\/td><\/tr><tr><td>Week:<\/td><td>6<\/td><\/tr><tr><td>Competencies:<\/td><td>Students will be able to effectively define and use variables, programming flow control.<\/td><\/tr><tr><td>BoKS:<\/td><td>\u00ad 3bK2, The student understands the principles of data related software like Python, R, Scala and\/or Java and knows how to write (basic) scripts.<\/td><\/tr><tr><td>Learning Goals:<\/td><td>Able read text files<\/td><\/tr><\/tbody><\/table><\/figure>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Text File I\/O<\/h2>\n\n\n\n<p>Before we start with how to handle files within Python, it\u2019s important to understand what is a file.<\/p>\n\n\n\n<p>At its core, a file is a contiguous set of bits (0 an 1s). This data is organized in a specific format and can be anything as simple as a text file or as complicated as a encoded image or an program executable.<\/p>\n\n\n\n<p>The data stored within files represents and may have different functions within the computer, it depends on the format specification used, which is typically represented by an extension. <\/p>\n\n\n\n<p>For example, a file that has an extension of\u00a0<code>.gif<\/code>\u00a0most likely conforms to the\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/GIF\">Graphics Interchange Format<\/a>\u00a0specification. There are hundreds, if not thousands, of\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/List_of_filename_extensions\">file extensions<\/a>\u00a0out there. For this tutorial, you\u2019ll only deal with\u00a0text files like <code>.txt<\/code>\u00a0or\u00a0<code>.csv<\/code>\u00a0file extensions.<\/p>\n\n\n\n<p>Text files are structured as a sequence of\u00a0characters, ended by a special character EOF (End of File). On most operating systems the file format that allows only plain text content with no formatting. Such files can be viewed and edited on\u00a0terminals and text editors, usually with additional information indicating an encoding.<\/p>\n\n\n\n<p>Text files have the typical characters like letters and digits, and punctuation, but also multiple special characters, like spaces, tabs and new lines. Interesting to know is that, different operating systems may use different rules, for example in Windows,  each line of text separated by a two-character combination:\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Carriage_return\">carriage return<\/a>\u00a0(CR) and\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Line_feed\">line feed<\/a>\u00a0(LF), while in Unix-lile OS, lines are separated by LFs and in MacOS are CR.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">File Encoding<\/h3>\n\n\n\n<p>In\u00a0computing,\u00a0data storage, and\u00a0data transmission,\u00a0<strong>encoding<\/strong>\u00a0is used to represent a repertoire of\u00a0characters for textual data.<\/p>\n\n\n\n<p>Early character codes associate optical representation or a binary value. And they could only represent a small subset of the characters used in\u00a0written languages, sometimes restricted to\u00a0Latin based characters, and digits representation and some\u00a0punctuation\u00a0only. With the reduction of the cost and evolution of transmissions more elaborate character codes (such as\u00a0<a href=\"https:\/\/en.wikipedia.org\/wiki\/Unicode\">Unicode<\/a>) may represent most of the characters used in many written languages. Character encoding using internationally accepted standards permits worldwide interchange of text in electronic form.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>Character<\/th><th>Unicode code point<\/th><th>Glyph<\/th><\/tr><tr><td>Latin A<\/td><td>U+0041<\/td><td>\u0391<\/td><\/tr><tr><td>Latin sharp S<\/td><td>U+00DF<\/td><td>\u00df<\/td><\/tr><tr><td>Han for East<\/td><td>U+6771<\/td><td>\u6771<\/td><\/tr><tr><td>Ampersand<\/td><td>U+0026<\/td><td>&amp;<\/td><\/tr><tr><td>Inverted exclamation mark<\/td><td>U+00A1<\/td><td>\u00a1<\/td><\/tr><tr><td>Section sign<\/td><td>U+00A7<\/td><td>\u00a7<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Text Editors<\/h2>\n\n\n\n<p>There are multiple text editors, and most of the programming editing interfaces are in their essence text editors, which attached compilers or interpreters. <\/p>\n\n\n\n<p>If you do use one, or do not have one you prefer, I suggest you get familiarized with one, you will be using it a lot, and there are specific features, like encoding, file browsing, syntax highlighting, macros, integration with source control, that can be very useful. Here are some of the most known:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><a href=\"https:\/\/atom.io\/\" target=\"_blank\" rel=\"noreferrer noopener\">Atom<\/a><\/li><li><a href=\"https:\/\/notepad-plus-plus.org\/\" target=\"_blank\" rel=\"noreferrer noopener\">Notepad++<\/a><\/li><li><a href=\"https:\/\/www.sublimetext.com\/\" target=\"_blank\" rel=\"noreferrer noopener\">Sublime Text<\/a>\u00a0<\/li><\/ul>\n\n\n\n<p>In the same working folder as your script, please create a text file (I named mine <em>testfile.txt<\/em>), and write something on it, it needs to have at least 2\/3 lines.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Read a file<\/h2>\n\n\n\n<p>Reading a file is really easy in Python. You request to open a file, you perform operations on it, and then you close it. <\/p>\n\n\n\n<p><strong>Closing a file is no only good coding, it is mandatory<\/strong>.<\/p>\n\n\n\n<p>Closing a file even on read operations it is important, the OS keeps track on which programs are reading and writing on each files, to avoid corruption (reading a section of a file, while another program is writing on it). So, open the file, do all the operation you must in an efficient  way and then close it.<\/p>\n\n\n\n<p>Data corruption can occur when two programs are competing for the same file, normally with at least one of them writing on the file. The operating system reduces the risk, but, does not fully eliminate it, more on this topic will be covered in during optimization<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">f = open('testfile.txt')\nprint(f.read())\nf.close() <\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;textile&quot;,&quot;mime&quot;:&quot;text\/x-textile&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Textile&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;textile&quot;}\">Hello World\nPlease store in somewhere safe!\nThis is the last, line! Bye<\/pre><\/div>\n\n\n\n<p>The second way to close a file is to use the&nbsp;<code>with<\/code>&nbsp;statement:<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">with open('testfile.txt') as f:\n    print(f.read())<\/pre><\/div>\n\n\n\n<p>The&nbsp;<code>with<\/code>&nbsp;statement automatically takes care of closing the file once it leaves the&nbsp;<code>with<\/code>&nbsp;block, even in cases of error. I highly recommend that you use the&nbsp;<code>with<\/code>&nbsp;statement as much as possible, as it allows for cleaner code and makes handling any unexpected errors easier for you.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Reading Opened Files<\/h2>\n\n\n\n<p>Once you\u2019ve opened up a file, you\u2019ll want to read its content. There are multiple methods that can be called on a file object to help you out:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Method<\/th><th>What It Does<\/th><\/tr><\/thead><tbody><tr><td><a href=\"https:\/\/docs.python.org\/3.7\/library\/io.html#io.RawIOBase.read\"><code>.read(size=-1)<\/code><\/a><\/td><td>This reads from the file based on the number of&nbsp;<code>size<\/code>&nbsp;bytes. If no argument is passed or&nbsp;<code>None<\/code>&nbsp;or&nbsp;<code>-1<\/code>&nbsp;is passed, then the entire file is read.<\/td><\/tr><tr><td><a href=\"https:\/\/docs.python.org\/3.7\/library\/io.html#io.IOBase.readline\"><code>.readline(size=-1)<\/code><\/a><\/td><td>This reads at most&nbsp;<code>size<\/code>&nbsp;number of characters from the line. This continues to the end of the line and then wraps back around. If no argument is passed or&nbsp;<code>None<\/code>&nbsp;or&nbsp;<code>-1<\/code>&nbsp;is passed, then the entire line (or rest of the line) is read.<\/td><\/tr><tr><td><a href=\"https:\/\/docs.python.org\/3.7\/library\/io.html#io.IOBase.readlines\"><code>.readlines()<\/code><\/a><\/td><td>This reads the remaining lines from the file object and returns them as a list.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Reading line by line<\/h4>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">with open('testfile.txt') as f:\n  line = f.readline()\n  while line != &quot;&quot;:\n    # do something with the line\n    print(line)\n    line = f.readline()<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">Hello World\n\nPlease store in somewhere safe!\n\nThis is the last, line! Bye\n<\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Count the number of lines in a file<\/h4>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">with open('testfile.txt') as f:\n    count = len(f.readlines())\nprint(count)<\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Show the first character of each line<\/h4>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">with open('testfile.txt') as f:\n  content = f.readlines()\n  for line in content:\n        print(line[0])<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">H\nP\nT<\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Show the last word of each line<\/h4>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">with open('testfile.txt') as f:\n  content = f.readlines()\n  for line in content:\n    \twords = line.split(' ')\n        print(words[-1])<\/pre><\/div>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:false,&quot;languageLabel&quot;:false,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;idea&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;language&quot;:&quot;Python&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;python&quot;}\">World\nsafe!\nBye<\/pre><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>uthor: Carlos Santos Learning Line: Programming Course: PR1: Introduction to Programming Week: 6 Competencies: Students will be able to effectively define and use variables, programming flow control. BoKS: \u00ad 3bK2, The student understands the principles of data related software like Python, R, Scala and\/or Java and knows how to write (basic) scripts. Learning Goals: Able [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":0,"parent":99,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-393","page","type-page","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>PR1 - Preparation for Week 7 - Reading a file - Applied Artificial Intelligence and Data Management<\/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:\/\/aaidm.buas.nl\/?page_id=393\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"PR1 - Preparation for Week 7 - Reading a file - Applied Artificial Intelligence and Data Management\" \/>\n<meta property=\"og:description\" content=\"uthor: Carlos Santos Learning Line: Programming Course: PR1: Introduction to Programming Week: 6 Competencies: Students will be able to effectively define and use variables, programming flow control. BoKS: \u00ad 3bK2, The student understands the principles of data related software like Python, R, Scala and\/or Java and knows how to write (basic) scripts. Learning Goals: Able [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/aaidm.buas.nl\/?page_id=393\" \/>\n<meta property=\"og:site_name\" content=\"Applied Artificial Intelligence and Data Management\" \/>\n<meta property=\"article:modified_time\" content=\"2020-08-26T15:22:33+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/aaidm.buas.nl\/?page_id=393\",\"url\":\"https:\/\/aaidm.buas.nl\/?page_id=393\",\"name\":\"PR1 - Preparation for Week 7 - Reading a file - Applied Artificial Intelligence and Data Management\",\"isPartOf\":{\"@id\":\"https:\/\/aaidm.buas.nl\/#website\"},\"datePublished\":\"2020-08-26T14:42:49+00:00\",\"dateModified\":\"2020-08-26T15:22:33+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/aaidm.buas.nl\/?page_id=393#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/aaidm.buas.nl\/?page_id=393\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/aaidm.buas.nl\/?page_id=393#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/aaidm.buas.nl\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Year 1\",\"item\":\"https:\/\/aaidm.buas.nl\/?page_id=80\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Year 1 &#8211; Block A\",\"item\":\"https:\/\/aaidm.buas.nl\/?page_id=82\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"PR1: Introduction to Programming\",\"item\":\"https:\/\/aaidm.buas.nl\/?page_id=99\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"PR1 &#8211; Preparation for Week 7 &#8211; Reading a file\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/aaidm.buas.nl\/#website\",\"url\":\"https:\/\/aaidm.buas.nl\/\",\"name\":\"Applied Artificial Intelligence and Data Management\",\"description\":\"Course Information\",\"publisher\":{\"@id\":\"https:\/\/aaidm.buas.nl\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/aaidm.buas.nl\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/aaidm.buas.nl\/#organization\",\"name\":\"Applied Artificial Intelligence and Data Management\",\"url\":\"https:\/\/aaidm.buas.nl\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/aaidm.buas.nl\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/aaidm.buas.nl\/wp-content\/uploads\/2020\/06\/buas-logo.png\",\"contentUrl\":\"https:\/\/aaidm.buas.nl\/wp-content\/uploads\/2020\/06\/buas-logo.png\",\"width\":382,\"height\":132,\"caption\":\"Applied Artificial Intelligence and Data Management\"},\"image\":{\"@id\":\"https:\/\/aaidm.buas.nl\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"PR1 - Preparation for Week 7 - Reading a file - Applied Artificial Intelligence and Data Management","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:\/\/aaidm.buas.nl\/?page_id=393","og_locale":"en_US","og_type":"article","og_title":"PR1 - Preparation for Week 7 - Reading a file - Applied Artificial Intelligence and Data Management","og_description":"uthor: Carlos Santos Learning Line: Programming Course: PR1: Introduction to Programming Week: 6 Competencies: Students will be able to effectively define and use variables, programming flow control. BoKS: \u00ad 3bK2, The student understands the principles of data related software like Python, R, Scala and\/or Java and knows how to write (basic) scripts. Learning Goals: Able [&hellip;]","og_url":"https:\/\/aaidm.buas.nl\/?page_id=393","og_site_name":"Applied Artificial Intelligence and Data Management","article_modified_time":"2020-08-26T15:22:33+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/aaidm.buas.nl\/?page_id=393","url":"https:\/\/aaidm.buas.nl\/?page_id=393","name":"PR1 - Preparation for Week 7 - Reading a file - Applied Artificial Intelligence and Data Management","isPartOf":{"@id":"https:\/\/aaidm.buas.nl\/#website"},"datePublished":"2020-08-26T14:42:49+00:00","dateModified":"2020-08-26T15:22:33+00:00","breadcrumb":{"@id":"https:\/\/aaidm.buas.nl\/?page_id=393#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/aaidm.buas.nl\/?page_id=393"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/aaidm.buas.nl\/?page_id=393#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/aaidm.buas.nl\/"},{"@type":"ListItem","position":2,"name":"Year 1","item":"https:\/\/aaidm.buas.nl\/?page_id=80"},{"@type":"ListItem","position":3,"name":"Year 1 &#8211; Block A","item":"https:\/\/aaidm.buas.nl\/?page_id=82"},{"@type":"ListItem","position":4,"name":"PR1: Introduction to Programming","item":"https:\/\/aaidm.buas.nl\/?page_id=99"},{"@type":"ListItem","position":5,"name":"PR1 &#8211; Preparation for Week 7 &#8211; Reading a file"}]},{"@type":"WebSite","@id":"https:\/\/aaidm.buas.nl\/#website","url":"https:\/\/aaidm.buas.nl\/","name":"Applied Artificial Intelligence and Data Management","description":"Course Information","publisher":{"@id":"https:\/\/aaidm.buas.nl\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/aaidm.buas.nl\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/aaidm.buas.nl\/#organization","name":"Applied Artificial Intelligence and Data Management","url":"https:\/\/aaidm.buas.nl\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/aaidm.buas.nl\/#\/schema\/logo\/image\/","url":"https:\/\/aaidm.buas.nl\/wp-content\/uploads\/2020\/06\/buas-logo.png","contentUrl":"https:\/\/aaidm.buas.nl\/wp-content\/uploads\/2020\/06\/buas-logo.png","width":382,"height":132,"caption":"Applied Artificial Intelligence and Data Management"},"image":{"@id":"https:\/\/aaidm.buas.nl\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/pages\/393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=393"}],"version-history":[{"count":2,"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/pages\/393\/revisions"}],"predecessor-version":[{"id":396,"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/pages\/393\/revisions\/396"}],"up":[{"embeddable":true,"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=\/wp\/v2\/pages\/99"}],"wp:attachment":[{"href":"https:\/\/aaidm.buas.nl\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=393"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}