Question: I have an Excel table saved as a CSV that looks something like (when it's in Excel) this just longer:

```
    Monday  Tuesday     Wednesday   Thursday    Friday
marsbar 9   8   0   6   5
reeses  0   0   0   9   0
twix    2   3   0   5   6
snickers    9   8   0   6   5

```

(The format isnt perfect, but you get the gist--candy bars/day). I want to write a program for python in which I could input a list of candy bar names in the program

```
>>> ['twix', 'reeses']

```

and it would give me the days of the week on which those candy bars were eaten and how many candy bars in the list were eaten on that day. The result would look something like this:

```
Monday 2
Tuesday 3
Wednesday 0
Thursday 14
Friday 6

```

could someone help me write such a program?

Answer: 
Maybe with the [csv module](http://docs.python.org/library/csv.html)

I suppose the delimiter is the tab character (`\t`)

```
import csv
reader = csv.reader(open('csv_file.csv', 'rb'), delimiter='\t')
for row in reader:
    print row

>>>['Monday','Tuesday', 'Wednesday', 'Thursday', 'Friday']
['marsbar', '9', '8','0', '6', '5']
['reeses', '0', '0', '0', '9', '0']
['twix', '2', '3', '0', '5', '6']
['snickers', '9', '8', '0',  '6',  '5']

```
Some useful bits:

If you have a list of lists like

```
[['marsbar', 0, 1, 2, 3, 4], ['twix', 3, 4, 5, 6, 7]]

```

(which you should be able to get by using the `csv` module)

You will probably want to convert it to a dictionary, where the first item of each list is used for the key, and the rest make up the value. You can do this with something like

```
dict((x[0], x[1]) for x in list_of_lists)

```

You can look up multiple keys with a list comprehension as well:

```
[the_dict[key] for key in key_list]

```

That gives you a list of lists, where you want to sum the first elements of each list, the second elements, etc. To do that, we 'zip' the lists to make a list of lists with all the first elements, all the second elements etc., and then sum the inner lists.

```
[sum(x) for x in zip(*the_requested_candybars)]

```

The `zip()` function takes multiple arguments; the `*` here turns the list of lists into several list arguments.

We can `zip` again to match up the week names with the sums.