{"id":20041713,"url":"https://github.com/ajithvcoder/session13_generatorsanditertools1","last_synced_at":"2026-06-09T19:31:19.300Z","repository":{"id":111987524,"uuid":"393484022","full_name":"ajithvcoder/Session13_GeneratorsandItertools1","owner":"ajithvcoder","description":"EPAi 3 - Assignment 13","archived":false,"fork":false,"pushed_at":"2021-08-06T19:45:42.000Z","size":23,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-27T17:23:37.214Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ajithvcoder.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2021-08-06T19:38:32.000Z","updated_at":"2021-08-06T19:45:45.000Z","dependencies_parsed_at":null,"dependency_job_id":"fc4ecd7f-3470-4833-ad5a-93233884d241","html_url":"https://github.com/ajithvcoder/Session13_GeneratorsandItertools1","commit_stats":null,"previous_names":["ajithvcoder/session13_generatorsanditertools1"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ajithvcoder/Session13_GeneratorsandItertools1","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession13_GeneratorsandItertools1","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession13_GeneratorsandItertools1/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession13_GeneratorsandItertools1/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession13_GeneratorsandItertools1/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ajithvcoder","download_url":"https://codeload.github.com/ajithvcoder/Session13_GeneratorsandItertools1/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ajithvcoder%2FSession13_GeneratorsandItertools1/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34123171,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T10:47:37.414Z","updated_at":"2026-06-09T19:31:19.208Z","avatar_url":"https://github.com/ajithvcoder.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"### Session 13 - Generators and Itertools 1\n\nGoogle Colab notebook - [here](https://colab.research.google.com/drive/1CCNAODxbF1GrQC_9RHcSgQIMLz7shFgU?usp=sharing)\n\n**iter()**\n```\nself.parking_index += 1\nfor num in range(len(self.information)):\n    tic_item = self.information[self.parking_index][1].split(\",\")\n    tic_item[-1] = tic_item[-1].replace(\"\\n\",\"\") \n    tic_item = self.type_caste(tic_item)\n    yield self.Ticket_header(*tic_item)\n```\n\nIter method is used to implement iterator with yield keyword. Here each line in the .csv file is taken and then processed and the fed as return when each time iterator is called. Not able to implement iterator properly so used NYCClassicParking method where next() is used\n\n\n**Namedtuple**\n```\ndef form_named_tuple(self, ticket_header):        \n    ticket_headers = ticket_header.strip('\\n').split(\",\")\n    ticket_headers = [n.replace(\" \",\"\") for n in ticket_headers]\n    Tickets = namedtuple(\"Tickets\",ticket_headers)\n    return Tickets\n```\nWe have took the first line and removed the spaces in each word and then we have formed a named tuple\n\n**Casting**\n```\ndef type_caste(self, data):\n    \"\"\"\n    :data : list of string\n    :return : type casting respective data type\n    \"\"\"\n    data = int(data[0]), data[1],data[2], data[3], datetime.datetime.strptime(data[4],\"%m/%d/%Y\"), int(data[5]), data[6],data[7], data[8]\n    return data\n```\nWe have casted each item in data to corresponding data type and then we are returning.\n\n**number_of_violations()**\n```\ndef number_of_violations(self):    \n    car_violate_dict = dict()\n    for num in range(len(self.information)):\n        tic_item = self.information[num][1].split(\",\")\n        tic_item[-1] = tic_item[-1].replace(\"\\n\",\"\")\n        if (tic_item[-1].find(\"VIOLATION\") != -1):\n            if tic_item[-2] not in car_violate_dict:\n                car_violate_dict[tic_item[-2]] = 1\n            else:\n                car_violate_dict[tic_item[-2]] += 1     \n    return car_violate_dict\n```\n\nWe are iterating and using a dictionary to store the information of violated cars name and its count in a lazy properties method\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Fsession13_generatorsanditertools1","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fajithvcoder%2Fsession13_generatorsanditertools1","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fajithvcoder%2Fsession13_generatorsanditertools1/lists"}