Question

pythin: Write a function named "computed_column" that takes a string as a parameter representing the name...

pythin: Write a function named "computed_column" that takes a string as a parameter representing the name of a CSV file with 5 columns in the format ",,,," and writes a file named "blank.csv" containing all the data from the input file but with a sixth column containing the sum of the values from the second and fourth columns

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def computed_column(filename):
    f = open(filename, 'r')
    w = open('blank.csv', 'w')
    for line in f:
        words = line.strip().split()
        w.write(line.strip() + "," + str(int(words[1]) + int(words[3])) + "\n")
    f.close()
    w.close()

Add a comment
Know the answer?
Add Answer to:
pythin: Write a function named "computed_column" 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
ADVERTISEMENT