Question

Python: Write a function named "filter_rows" that takes a string as a parameter representing the name...

Python:

Write a function named "filter_rows" that takes a string as a parameter representing the name of a CSV file with 5 columns in the format "<string>,<int>,<int>,<int>,<int>" and writes a file named "invite.csv" containing the rows from the input file where the value in the fifth column is greater than 101

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def filter_rows(filename):
    f = open(filename, 'r')
    w = open("invite.csv", 'w')
    for line in f:
        words = line.strip().split(",")
        if int(words[4]) > 101:
            w.write(line)
    f.close()
    w.close()

Add a comment
Know the answer?
Add Answer to:
Python: Write a function named "filter_rows" that takes a string as a parameter representing the name...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT