{"id":26777847,"url":"https://github.com/eryks1999/data-collection-project_python","last_synced_at":"2026-04-16T08:36:33.630Z","repository":{"id":284353468,"uuid":"954642979","full_name":"ErykS1999/Data-collection-project_Python","owner":"ErykS1999","description":"This project allowed me to practice classes, populating json files as well as extracting data. ","archived":false,"fork":false,"pushed_at":"2025-03-25T12:35:54.000Z","size":4,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T13:41:05.137Z","etag":null,"topics":["data","git","json","python"],"latest_commit_sha":null,"homepage":"","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/ErykS1999.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2025-03-25T11:54:33.000Z","updated_at":"2025-03-25T12:35:57.000Z","dependencies_parsed_at":"2025-03-25T13:41:07.597Z","dependency_job_id":"af4071a4-e913-438a-931c-3191c51354bf","html_url":"https://github.com/ErykS1999/Data-collection-project_Python","commit_stats":null,"previous_names":["eryks1999/data-collection-project_python"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErykS1999%2FData-collection-project_Python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErykS1999%2FData-collection-project_Python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErykS1999%2FData-collection-project_Python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ErykS1999%2FData-collection-project_Python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ErykS1999","download_url":"https://codeload.github.com/ErykS1999/Data-collection-project_Python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246140585,"owners_count":20729802,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["data","git","json","python"],"created_at":"2025-03-29T05:18:13.556Z","updated_at":"2026-04-16T08:36:33.497Z","avatar_url":"https://github.com/ErykS1999.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Managing data between py \u0026 json\n\n\n## Top tips ( from an amateur) when creating a local database in python using json:\n\n1- Always remember the PEP-8 method when writing your code. The document needs appropriate indentation as well as clear readability. \n\n  ```\nimport json\n\n\nclass Security:\n\n    def __init__(self,safe_data=None):\n        self.safe_data = safe_data if safe_data else {}\n\n\n\n    def workforce(self):\n        \n\n        self.safe_data = {\n            \"mike\":\"jambo1\",\n            \"sam\":\"sun1\",\n            \"eric\":\"sushi2\",\n            \"pat\":\"cati\",\n            \"bob\":\"dogi1\"\n        }\n\n        \n\n    def save_new_file(self,filename = \"employee_data.json\"):\n        if not self.safe_data:\n            print(\"No data to save. Run workforce() first.\")\n            return\n        try:\n            with open(filename,'w',encoding='UTF-8') as f:\n                json.dump(self.safe_data,f,indent=4)\n            print(f\"The data has been successfully saved to {filename}\")\n        except Exception as e: # exception handles all of the general problems \n            print(f\"An error has occured while saving this file: {e}\")\n\n\n\n  ```\n2- When working in classes, make sure to group every different section into methods(functions). This will help you not to get lost whilst working on your project.\n\n  ```\n  def information(self):\n\n        print(\"This is the data which we currently have about your database\")\n        print(self.data)\n\n    \n    def input_information(self):\n        ask = input(\" What is your username on the website?  \")\n        if ask not in self.data:\n            self.data[ask] = {}\n            print(f\"\\nDear {ask}, your information will be put through. \")\n        else:\n            print(\"\\nWe already have this username.\")\n                \n\n    def save_information(self):\n        try:\n            with open('database.json','w',encoding='UTF-8') as f:\n                json.dump(data,f,indent=4)\n        except(FileNotFoundError,json.JSONDecodeError):\n            print(\"You have some error in reading the code. \")\n\n  ```\n3- Find learn to master try and except:\n   During this small project, I had some challenges with adapting the right techniques when it comes to try and except. Remember that \n   the 'exception' clause as below handles all of the general problems. Make sure to mention in your try and except the potential errors that can come up\n   such as ValueError or FileNotFound and adapt the print message to each. \n\n  ```\n        try:\n            with open(filename,'w',encoding='UTF-8') as f:\n                json.dump(self.safe_data,f,indent=4)\n            print(f\"The data has been successfully saved to {filename}\")\n        except Exception as e: # exception handles all of the general problems \n            print(f\"An error has occured while saving this file: {e}\")\n  ```\n\nInstead try this:\n\n  ```\n        try:\n            with open('database.json','w',encoding='UTF-8') as f:\n                json.dump(data,f,indent=4)\n        except(FileNotFoundError,json.JSONDecodeError):\n            print(\"You have some error in reading the code. \")\n  ```\n\n\n4- Repeat even the basics. In this project, I had some issues with extracting specific data from the dictionaries within the json files. \n   I had an empty gap within my brain which forced me to ask myself a question 'do I know how to extract the data from the dictionaries?'.\n   The answer was 'no', So i opened a new file and practiced until I understood it again. Always come back to the basics and ask yourself rhetorical question.\n\n\n5- Over-complication.\n   Never add more than you need to. I had the tendancy to add 'else' clauses everytime the 'if' came up but that is not always necessary.\n   Go over the code couple of times and ask yourself 'how can I make this simpler'? \n\n\n\n\n## Please create pull requests if you feel that something is done wrong. I love to learn from my mistakes. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feryks1999%2Fdata-collection-project_python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feryks1999%2Fdata-collection-project_python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feryks1999%2Fdata-collection-project_python/lists"}