Warning: The magic method Slickr_Flickr_Plugin::__wakeup() must have public visibility in /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php on line 152

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831

Warning: Cannot modify header information - headers already sent by (output started at /home/kenbauer/public_kenscourses/tc101fall2015/wp-content/plugins/slickr-flickr/classes/class-plugin.php:152) in /home/kenbauer/public_kenscourses/tc101fall2015/wp-includes/rest-api/class-wp-rest-server.php on line 1831
{"id":27259,"date":"2015-11-24T12:01:33","date_gmt":"2015-11-24T18:01:33","guid":{"rendered":"http:\/\/charliegdrummer.wordpress.com\/?p=198"},"modified":"2015-11-24T12:01:33","modified_gmt":"2015-11-24T18:01:33","slug":"wsq16-opening-files-and-reading-them","status":"publish","type":"post","link":"https:\/\/kenscourses.com\/tc101fall2015\/2015\/wsq16-opening-files-and-reading-them\/","title":{"rendered":"WSQ16: Opening files and reading them"},"content":{"rendered":"

The WSQ16 is about doing a program that reads a file abaut cars and it’s specifications. The file is read such as the first 14 characters are the model o f the car, the character from 53 to 54, the miles per gallon in city, and so on.<\/p>\n

So it asks you to give the user the\u00a0average gas mileage in city (City MPG),\u00a0average gas mileage on highway (Highway MPG), and the\u00a0average midrange price of the vehicles in the set.<\/p>\n

To accomplish that, I searched for a way to import text files to python and how to read it.<\/p>\n

I learned that you can open the file, the easy way, \u00a0with the command open(“nameofthefile.extension”)…. yeah, that simple.<\/p>\n

Then, the hard part goes on, read the file<\/p>\n

Let’s say you code this<\/p>\n

file = openfile(“filename.ext”)<\/p>\n

The token file has the file in it.<\/p>\n

The file can be read line by line with the command file.readline()
\nThe file can be read entirely and set as a list with the command file.read()<\/p>\n

Through websurfing I learned another way; you can read text lines with for loops; you just have to tell the computer for each line inside this variable do:<\/p>\n

And the result of hte coding is:<\/p>\n

for line in\u00a0file<\/p>\n

After discoveringt that, the coding was so easier.<\/p>\n

It all abaout substrings; I already know what spaces are what thing, so I just substring with line[start:end] <\/em>so its easy then, just have to assing a variable like carmodel or cmpg and print it continiously inside the loop.<\/p>\n

The last problem was that I didn’t need the even lines, so with an if and the condition a counter is even, I skipped every even line.<\/p>\n

Here is the result:<\/p>\n

\"Capture\"<\/p>\n

As always<\/p>\n

Github Link<\/span><\/a><\/p>\n

 <\/p>\n

\"7\"<\/p>\n

 <\/p>\n

\"\"<\/a> \"\"<\/p>\n","protected":false},"excerpt":{"rendered":"

The WSQ16 is about doing a program that reads a file abaut cars and it’s specifications. The file is read such as the first 14 characters are the model o f the car, the character from 53 to 54, the miles per gallon in city, … Continúa leyendo WSQ16: Opening files and reading them<\/span><\/a>\"\"<\/p>\n","protected":false},"author":191,"featured_media":27257,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[45,437,39],"_links":{"self":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27259"}],"collection":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/users\/191"}],"replies":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/comments?post=27259"}],"version-history":[{"count":1,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27259\/revisions"}],"predecessor-version":[{"id":27260,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/posts\/27259\/revisions\/27260"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media\/27257"}],"wp:attachment":[{"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/media?parent=27259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/categories?post=27259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kenscourses.com\/tc101fall2015\/wp-json\/wp\/v2\/tags?post=27259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}