{"action":"created","issue":{"url":"https://api.github.com/repos/Knio/pynmea2/issues/42","labels_url":"https://api.github.com/repos/Knio/pynmea2/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/Knio/pynmea2/issues/42/comments","events_url":"https://api.github.com/repos/Knio/pynmea2/issues/42/events","html_url":"https://github.com/Knio/pynmea2/pull/42","id":108389341,"number":42,"title":"Added NMEAFile class","user":{"login":"lobocv","id":6772396,"avatar_url":"https://avatars.githubusercontent.com/u/6772396?v=3","gravatar_id":"","url":"https://api.github.com/users/lobocv","html_url":"https://github.com/lobocv","followers_url":"https://api.github.com/users/lobocv/followers","following_url":"https://api.github.com/users/lobocv/following{/other_user}","gists_url":"https://api.github.com/users/lobocv/gists{/gist_id}","starred_url":"https://api.github.com/users/lobocv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lobocv/subscriptions","organizations_url":"https://api.github.com/users/lobocv/orgs","repos_url":"https://api.github.com/users/lobocv/repos","events_url":"https://api.github.com/users/lobocv/events{/privacy}","received_events_url":"https://api.github.com/users/lobocv/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-09-25T19:06:16Z","updated_at":"2015-09-27T23:24:34Z","closed_at":"2015-09-25T19:27:45Z","pull_request":{"url":"https://api.github.com/repos/Knio/pynmea2/pulls/42","html_url":"https://github.com/Knio/pynmea2/pull/42","diff_url":"https://github.com/Knio/pynmea2/pull/42.diff","patch_url":"https://github.com/Knio/pynmea2/pull/42.patch"},"body":"I've added a NMEAFile class that behaves just like a python file object. This class can be used to read NMEASentence objects from files in a manner analogous to the python file object. This means you can iterate through the NMEAFile object, call read() to return a list of all the lines as NMEASentences.\r\n\r\nFor example:\r\n`\r\n\r\n    with pynmea.NMEAFile(filepath) as f:\r\n        for nmea_string in f:\r\n                print nmea_string.latitude, nmea_string.longitude\r\n\r\n`\r\n  "},"comment":{"url":"https://api.github.com/repos/Knio/pynmea2/issues/comments/143602679","html_url":"https://github.com/Knio/pynmea2/pull/42#issuecomment-143602679","issue_url":"https://api.github.com/repos/Knio/pynmea2/issues/42","id":143602679,"user":{"login":"lobocv","id":6772396,"avatar_url":"https://avatars.githubusercontent.com/u/6772396?v=3","gravatar_id":"","url":"https://api.github.com/users/lobocv","html_url":"https://github.com/lobocv","followers_url":"https://api.github.com/users/lobocv/followers","following_url":"https://api.github.com/users/lobocv/following{/other_user}","gists_url":"https://api.github.com/users/lobocv/gists{/gist_id}","starred_url":"https://api.github.com/users/lobocv/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lobocv/subscriptions","organizations_url":"https://api.github.com/users/lobocv/orgs","repos_url":"https://api.github.com/users/lobocv/repos","events_url":"https://api.github.com/users/lobocv/events{/privacy}","received_events_url":"https://api.github.com/users/lobocv/received_events","type":"User","site_admin":false},"created_at":"2015-09-27T23:24:34Z","updated_at":"2015-09-27T23:24:34Z","body":"Well the problem I have (and hopefully you can clear it up) is \r\n1) That next() was returning lists of what seems like single NMEASentences.\r\n\r\n2) Requirement of an infinite while loop around a call to next() in order to read the entire file. I did not like the example have having an infinite while loop around a call to next() in order to read a file because it never exits once the file is exhausted.\r\n\r\nMy inclination is that it was designed to read from a source of constantly updating information (a steam). In that case it is of course useful to continuously call next() in a while loop. It was because I did not fully understand the purpose of the NMEAStreamReader that I did not subclass it/extend it.\r\n\r\nIf in fact it is meant to read from a constantly updating source I feel it might be simpler to have the NMEAFile.\r\n\r\nI've taken @Knio 's comments to heart and they worked out. By implementing the same interface through defining of __iter__(), __enter__(), __exit__(), open(), close() I've successfully ran the test scripts on python 2.7 and 3.4.\r\n\r\n\r\n"}}