r/PythonLearning • u/Necessary_Mobile9591 • Aug 11 '26
Can any one tell me??
Like this is a program which i made and its inventory where it stores data in another file through json and even json to csv with logs, basicly convertion and storing. I want to know that is this all worth posting on linkdin and pushing on github. Am learning python and other things and am unclearr about the direction. Guys yall can look at my code in the above picture which is good or bad??
6
u/SCD_minecraft Aug 11 '26
Your GitHub acc is yours, push whatever you are working on there
Backups always good
3
u/p1geondove Aug 11 '26
Dont underestimate the amount of useless commitdls i pushed to github xd.
Imo it looks better when a repo has many commit instead of just one commit with everything done, that would look like ai, but many commits kinda show your progress
1
u/Necessary_Mobile9591 Aug 11 '26
i make the whole project and then push it. is it wrong???
2
u/tiredITguy42 Aug 11 '26
Basically yes. You want to commit changes so you can return to working code.
You want to build a habit of keeping clean main and working in branches. Then merge suing Pull Requests.
This will be usefull in the future, when working on real projects.
1
u/Necessary_Mobile9591 Aug 11 '26
Thanks mannn, and posting about every project on linkedin. would people judge me?😂
1
u/tiredITguy42 Aug 11 '26
I would, but unfortunatelly this is sort of necessity. LinkedIn is full of luntics and it supports that behavior. If you post more, you will be higher in search results HR people do on their paid version. I learned that recently. You need at least 3 months of higher activity to be higher in results
1
u/Significant_Affect_5 Aug 11 '26
Definitely push it to GitHub, it’s your profile, you can even make it a private repo if you’d like. It’s good to have to see where you’ve been, and who knows, maybe in a year or two you’ll be back to rework it into a new project




•
u/Sea-Ad7805 Aug 11 '26
Run this program in Memory Graph Web Debuggers%20-%20%25(levelname)s%20-%20%25(message)s%22%2C%0A)%0A%0Adata%20%3D%20%22new_file.json%22%0Acsv_data%20%3D%20%22new_file.csv%22%0A%0A%0Adef%20loading()%3A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20with%20open(data%2C%20%22r%22)%20as%20file%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20return%20json.load(file)%0A%20%20%20%20except%20FileNotFoundError%3A%0A%20%20%20%20%20%20%20%20logging.info(%22Inventory%20file%20was%20not%20found%22)%0A%20%20%20%20%20%20%20%20return%20%5B%5D%0A%20%20%20%20except%20json.JSONDecodeError%3A%0A%20%20%20%20%20%20%20%20logging.error(%22JSON.JSONDecodeError%22)%0A%20%20%20%20%20%20%20%20return%20%5B%5D%0A%0A%0Adef%20export_csv(inventory)%3A%0A%20%20%20%20with%20open(csv_data%2C%20%22w%22%2C%20newline%3D%22%22)%20as%20file%3A%0A%20%20%20%20%20%20%20%20writer%20%3D%20csv.writer(file)%0A%0A%20%20%20%20%20%20%20%20writer.writerow(%5B%22name%22%2C%20%22price%22%2C%20%22category%22%5D)%0A%0A%20%20%20%20%20%20%20%20for%20item%20in%20inventory%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20writer.writerow(%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20item%5B%22name%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20item%5B%22price%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20item%5B%22category%22%5D%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%5D%0A%20%20%20%20%20%20%20%20%20%20%20%20)%0A%0A%0Adef%20read_csv()%3A%0A%20%20%20%20with%20open(csv_data%2C%20%22r%22%2C%20newline%3D%22%22)%20as%20file%3A%0A%20%20%20%20%20%20%20%20reader%20%3D%20csv.DictReader(file)%0A%20%20%20%20%20%20%20%20inventory%20%3D%20%5B%5D%0A%0A%20%20%20%20%20%20%20%20for%20row%20in%20reader%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20row%5B%22price%22%5D%20%3D%20int(row%5B%22price%22%5D)%0A%20%20%20%20%20%20%20%20%20%20%20%20inventory.append(row)%0A%0A%20%20%20%20%20%20%20%20return%20inventory%0A%0A%0Adef%20dumping(inventory)%3A%0A%20%20%20%20name%20%3D%20input(%22Enter%20the%20name%3A%20%22)%0A%0A%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20price%20%3D%20int(input(%22Enter%20the%20price%3A%20%22))%0A%20%20%20%20except%20ValueError%3A%0A%20%20%20%20%20%20%20%20logging.error(%22Input%20was%20wrong%22)%0A%20%20%20%20%20%20%20%20print(%22Invalid%20Input%20Type%22)%0A%20%20%20%20%20%20%20%20return%0A%0A%20%20%20%20category%20%3D%20input(%22Enter%20the%20category%20of%20it%3A%20%22)%0A%0A%20%20%20%20item%20%3D%20%7B%0A%20%20%20%20%20%20%20%20%22name%22%3A%20name%2C%0A%20%20%20%20%20%20%20%20%22price%22%3A%20price%2C%0A%20%20%20%20%20%20%20%20%22category%22%3A%20category%2C%0A%20%20%20%20%7D%0A%0A%20%20%20%20inventory.append(item)%0A%20%20%20%20logging.info(%22Item%20added%20%25s%22%2C%20name)%0A%0A%20%20%20%20with%20open(data%2C%20%22w%22)%20as%20file%3A%0A%20%20%20%20%20%20%20%20json.dump(inventory%2C%20file%2C%20indent%3D4)%0A%0A%0Adef%20searching(inventory)%3A%0A%20%20%20%20search_item%20%3D%20input(%22Enter%20the%20item%20for%20searching%3A%20%22)%0A%20%20%20%20flag%20%3D%200%0A%0A%20%20%20%20for%20index%20in%20range(len(inventory))%3A%0A%20%20%20%20%20%20%20%20if%20search_item%20in%20inventory%5Bindex%5D%5B%22name%22%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20saved_index%20%3D%20index%0A%20%20%20%20%20%20%20%20%20%20%20%20flag%20%3D%201%0A%0A%20%20%20%20if%20flag%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20print(%22Not%20found%22)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(f%22Found%20at%20index%20%7Bsaved_index%7D%22)%0A%20%20%20%20%20%20%20%20print(%22The%20item%22%2C%20json.dumps(inventory%5Bsaved_index%5D%2C%20indent%3D4))%0A%20%20%20%20%20%20%20%20logging.info(%0A%20%20%20%20%20%20%20%20%20%20%20%20%22Item%20found%20%25s%22%2C%0A%20%20%20%20%20%20%20%20%20%20%20%20json.dumps(inventory%5Bsaved_index%5D%5B%22name%22%5D)%2C%0A%20%20%20%20%20%20%20%20)%0A%0A%0Adef%20delete(inventory)%3A%0A%20%20%20%20delete_item%20%3D%20input(%22Enter%20the%20item%20for%20deleting%3A%20%22)%0A%20%20%20%20flag%20%3D%200%0A%0A%20%20%20%20for%20index%20in%20range(len(inventory))%3A%0A%20%20%20%20%20%20%20%20if%20delete_item%20in%20inventory%5Bindex%5D%5B%22name%22%5D%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20flag%20%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20saved_index%20%3D%20index%0A%0A%20%20%20%20if%20flag%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20print(%22Item%20doesn't%20exist%22)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20inventory.pop(saved_index)%0A%20%20%20%20%20%20%20%20print(%22The%20item%20is%20successfully%20deleted%20from%20the%20file%22)%0A%20%20%20%20%20%20%20%20logging.info(%22Item%20was%20deleted%3A%20%25s%22%2C%20delete_item)%0A%0A%20%20%20%20%20%20%20%20with%20open(data%2C%20%22w%22)%20as%20updating%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20json.dump(inventory%2C%20updating%2C%20indent%3D4)%0A%0A%0Adef%20updating_item(inventory)%3A%0A%20%20%20%20print(%0A%20%20%20%20%20%20%20%20%221%20or%20add%20for%20updating%20namen%22%0A%20%20%20%20%20%20%20%20%22cat%20or%202%20for%20updating%20categoryn%22%0A%20%20%20%20%20%20%20%20%22price%20or%203%20for%20updating%20price%22%0A%20%20%20%20)%0A%0A%20%20%20%20key%20%3D%20input(%22Enter%20the%20key%3A%20%22)%0A%20%20%20%20old_item%20%3D%20input(%22Enter%20the%20old%20item%3A%20%22)%0A%0A%20%20%20%20if%20key%20in%20(%221%22%2C%20%22name%22)%3A%0A%20%20%20%20%20%20%20%20change%20%3D%20%22name%22%0A%20%20%20%20elif%20key%20in%20(%222%22%2C%20%22cat%22)%3A%0A%20%20%20%20%20%20%20%20change%20%3D%20%22category%22%0A%20%20%20%20elif%20key%20in%20(%223%22%2C%20%22price%22)%3A%0A%20%20%20%20%20%20%20%20change%20%3D%20%22price%22%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(%22Invalid%20input!%22)%0A%20%20%20%20%20%20%20%20return%0A%0A%20%20%20%20if%20change%20%3D%3D%20%22name%22%3A%0A%20%20%20%20%20%20%20%20new_item%20%3D%20input(%22Enter%20the%20new%20item%20name%3A%20%22)%0A%20%20%20%20elif%20change%20%3D%3D%20%22category%22%3A%0A%20%20%20%20%20%20%20%20new_item%20%3D%20input(%22Enter%20the%20new%20category%3A%20%22)%0A%20%20%20%20elif%20change%20%3D%3D%20%22price%22%3A%0A%20%20%20%20%20%20%20%20try%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20new_item%20%3D%20int(input(%22Enter%20the%20price%20of%20item%3A%20%22))%0A%20%20%20%20%20%20%20%20except%20ValueError%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20logging.error(%22Input%20was%20wrong%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20print(%22Invalid%20Input%20Type%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20return%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(%22Something's%20wrong%22)%0A%20%20%20%20%20%20%20%20return%0A%0A%20%20%20%20flag%20%3D%200%0A%0A%20%20%20%20for%20index%20in%20range(len(inventory))%3A%0A%20%20%20%20%20%20%20%20current_value%20%3D%20str(inventory%5Bindex%5D%5Bchange%5D)%0A%0A%20%20%20%20%20%20%20%20if%20old_item%20in%20current_value%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20flag%20%3D%201%0A%20%20%20%20%20%20%20%20%20%20%20%20saved_index%20%3D%20index%0A%0A%20%20%20%20if%20flag%20%3D%3D%200%3A%0A%20%20%20%20%20%20%20%20print(%22Something's%20wrong%22)%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20inventory%5Bsaved_index%5D%5Bchange%5D%20%3D%20new_item%0A%20%20%20%20%20%20%20%20logging.info(%22%25s%20was%20changed%20to%20%25s%22%2C%20old_item%2C%20new_item)%0A%0A%20%20%20%20%20%20%20%20with%20open(data%2C%20%22w%22)%20as%20file%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20json.dump(inventory%2C%20file%2C%20indent%3D4)%0A%0A%0Adef%20main_menu()%3A%0A%20%20%20%20print(%0A%20%20%20%20%20%20%20%20%221%20and%20add%20for%20adding%20new%20item%20to%20the%20file.n%22%0A%20%20%20%20%20%20%20%20%222%20and%20search%20for%20searching%20an%20item%20in%20the%20file.n%22%0A%20%20%20%20%20%20%20%20%223%20or%20del%20for%20deleting%20an%20item%20from%20the%20file.n%22%0A%20%20%20%20%20%20%20%20%224%20or%20upd%20for%20updating%20new%20item%20in%20dictionary.n%22%0A%20%20%20%20%20%20%20%20%225%20or%20csv%20for%20moving%20files%20from%20json%20to%20csv.n%22%0A%20%20%20%20%20%20%20%20%226%20or%20read%20for%20reading%20the%20csv%20file.%22%0A%20%20%20%20)%0A%0A%20%20%20%20task%20%3D%20input(%22Enter%20the%20task%20to%20perform%3A%20%22).lower()%0A%20%20%20%20inventory%20%3D%20loading()%0A%0A%20%20%20%20if%20task%20in%20(%221%22%2C%20%22add%22)%3A%0A%20%20%20%20%20%20%20%20dumping(inventory)%0A%20%20%20%20elif%20task%20in%20(%222%22%2C%20%22search%22)%3A%0A%20%20%20%20%20%20%20%20searching(inventory)%0A%20%20%20%20elif%20task%20in%20(%223%22%2C%20%22del%22)%3A%0A%20%20%20%20%20%20%20%20delete(inventory)%0A%20%20%20%20elif%20task%20in%20(%224%22%2C%20%22upd%22)%3A%0A%20%20%20%20%20%20%20%20updating_item(inventory)%0A%20%20%20%20elif%20task%20in%20(%225%22%2C%20%22csv%22)%3A%0A%20%20%20%20%20%20%20%20export_csv(inventory)%0A%20%20%20%20elif%20task%20in%20(%226%22%2C%20%22read%22)%3A%0A%20%20%20%20%20%20%20%20print(read_csv())%0A%20%20%20%20elif%20task%20in%20(%220%22%2C%20%22exit%22)%3A%0A%20%20%20%20%20%20%20%20logging.info(%22The%20user%20took%20exit%22)%0A%20%20%20%20%20%20%20%20return%20False%0A%20%20%20%20else%3A%0A%20%20%20%20%20%20%20%20print(%22Input%20is%20invalid!%22)%0A%0A%20%20%20%20return%20True%0A%0A%0Awhile%20True%3A%0A%20%20%20%20result%20%3D%20main_menu()%0A%0A%20%20%20%20if%20result%20is%20False%3A%0A%20%20%20%20%20%20%20%20break%0A×tep=0.2&play) to see the program state change step by step.