#๐ Im having issues indexing a file with limited functions
18 messages ยท Page 1 of 1 (latest)
@hidden monolith
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.
You need to provide more detail about your problems.
Original post got cut because of a .py file
The first photo is the limits, second is the prompt I'm having issues with, third is an ex of how my professor wants a similar problem coded
#5 is the problem i need help on
Its mainly being able to parse through the file to identify individual values associated with a name
Wouldn't you just read the file and ignore lines where the name column does not equal the name you're interested in?
for row in csvr:
if row[4] != the_name:
continue
... use the row ...
I need the data associated with the Name to calculate the average
Yes. The above loop reads the entire file, but skips records not associated with the name.
Sure.
So you're not really "indexing" the file, you're just scanning it and considering only the records of interest.
Gotcha. I also need to calculate the class average for the name based on the type of class such as IT or CS
Sure. Just keep two tallies. Or a dict with a tally per class type, and there may be just the 2 types.
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, 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.