[Tutor] quick data structures question
delegbede at dudupay.com
delegbede at dudupay.com
Wed Sep 21 08:31:26 CEST 2011
Hi Fred,
Here is my attempt to solve your task.
import xlrd
def extract(file_name):
choice_file = xlrd.open_workbook(file_name)
choice_sheet = choice_file.sheet_by_index(0)
gene_dict = {}
for row_num in range(1,choice_sheet.nrows):
row_vals = choice_sheet.row_values(row_num)
if int(row_vals[0] * 100) > 20:
gene_dict[row_vals[1]] = row_vals[0] * 100
return gene_dict
Here are few assumptions I made.
1. The your excel file has just two column with headers. Column 1 is High gain written in YYYY% format and column 2 is the gene.
2. that excel returns YYYY% format as decimals which is float in python; hence my conversion to int.
Try this out and let me know how it goes.
Watch the indents carefully. I typed from my blackberry.
HTH.
Sent from my BlackBerry wireless device from MTN
-----Original Message-----
From: Fred G <bayespokerguy at gmail.com>
Sender: tutor-bounces+delegbede=dudupay.com at python.org
Date: Tue, 20 Sep 2011 23:28:43
To: <tutor at python.org>
Subject: [Tutor] quick data structures question
_______________________________________________
Tutor maillist - Tutor at python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list