-5

File #28 contains the following information:
Example data
Salesperson's name|Division (North, South, East, West)|Number of contacts made for the week|Amount of sales for the week overall
Jim Smith | West | 34 | 8,500
Sue Jones | North | 53 | 12,250
Sally Johnson | North | 48 | 11,350
Tim Riggs | East | 44 | 9,850

Develop a program that prints out detailed lines with each person’s name, number of contacts, sales amount, and average sale amount per contact made. At the end of the report print the totals for number of contacts and sales amount.

This is a problem I am working on for class and am looking for an idea of how to start it.

Things tried so far

code

list = [] 
f = open('file28.txt') 
line = f.readline()
while len(line) != 0:
    list = line.split()
    line = f.readline()
    print list 

I had it to the point where i had everything in a list. After that point I don't know where to go. I'm not even sure if this is the easiest way to start it.

Ja8zyjits
  • 1,433
  • 16
  • 31
  • list = [] f = open('file28.txt') line = f.readline() while len(line) != 0: list = line.split() line = f.readline() print list I had it to the point where i had everything in a list. After that point I don't know where to go. I'm not even sure if this is the easiest way to start it. – Brandon Hebel Dec 15 '15 at 02:45

1 Answers1

0

Well, to start, you're going to want to look into doing File I/O in Python. Lucky for you its pretty easy.

http://www.tutorialspoint.com/python/python_files_io.htm

To be able to get the separate information about each employee, you should learn about the split function and other string manipulators and parsers.

http://www.tutorialspoint.com/python/string_split.htm

And lastly you will need to deal with lists for handling the data.

http://www.tutorialspoint.com/python/python_lists.htm

I think you should be able to figure out the rest.

Good luck!

m_callens
  • 6,100
  • 8
  • 32
  • 54
  • Everything is good but the last problem is that i need to multiply two parts of the list list[3]*list[4] list3 being 35 and list4 being 8,500. The comma makes it so I can't, does anyone know how to get around this? – Brandon Hebel Dec 15 '15 at 04:00
  • http://stackoverflow.com/questions/642154/how-to-convert-strings-into-integers-in-python – Quantico Dec 15 '15 at 17:52