#๐Ÿ”’ Im having issues indexing a file with limited functions

18 messages ยท Page 1 of 1 (latest)

verbal currentBOT
#

@hidden monolith

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.

unkempt plinth
#

You need to provide more detail about your problems.

hidden monolith
#

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

hidden monolith
#

Its mainly being able to parse through the file to identify individual values associated with a name

unkempt plinth
#

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 ...
hidden monolith
#

I need the data associated with the Name to calculate the average

unkempt plinth
#

Yes. The above loop reads the entire file, but skips records not associated with the name.

hidden monolith
#

I see

#

Let me get home and try that

unkempt plinth
#

Sure.

#

So you're not really "indexing" the file, you're just scanning it and considering only the records of interest.

hidden monolith
#

Gotcha. I also need to calculate the class average for the name based on the type of class such as IT or CS

unkempt plinth
#

Sure. Just keep two tallies. Or a dict with a tally per class type, and there may be just the 2 types.

verbal currentBOT
#
Python help channel closed

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.