#๐Ÿ”’ Need help with file handling

34 messages ยท Page 1 of 1 (latest)

valid holly
#

I am a begginer(learning for 20 days) and I am building a study tracker project, it should be able to add or remove subjects, view subjects, add or remove chapters to subjects, view chapters of a subject, add notes or remove notes to a subject,

Right now I have implemented the adding the removing and viewing of subjects, but I am stuck at the chapters part, how should I add chapters to a subject

My file structure
Study tracker python project------
subjects.txt
chapters.txt
notes.txt

My current code:
https://pastebin.com/keMWw226

solemn snowBOT
#

@valid holly

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

wheat prairie
#

why this complicated approach?

#

Il tell u a really simple approach

#

you store data in text

valid holly
wheat prairie
#

in form of json

#

kinda like this

valid holly
wheat prairie
#

{
"Math": {
"chapters": ["Linear Equation", "Trigonometry"],
"notes": []
}
}

wheat prairie
# valid holly What's json

how about you learn about lists, dicts and different DSA things in python and then start this project??

#

dictionaries are like structured way to store ur data

valid holly
wheat prairie
#

but u can store in text

#

in simple words

#

if u take a dict's value and store it in a file

#

it becomes json

#

get it?

valid holly
#

Ok

wheat prairie
valid holly
wheat prairie
#

store everything in a single text file

#

in form of a value of dict

#

liike that

#

@valid holly i have a better suggestion

#

why dont u actually learn about json

#

its kinda easy once u learnt

valid holly
wheat prairie
rare obsidian
#

I agree, the main thing imo is that using a dict to represent the structure of your data is the most important thing. It makes you think about the problem better, e.g. chapters are always in the context of some particular subject, so your program should probably be changed to reflect that. Json is just an easy way to store the dict.

solemn snowBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.