Hi there,
My problem involves reading in and working with an excel file that contains blank cells randomly throughout the spreadsheet. The reason there are blank cells is because I have expression data for various cell types but for some of the cell types the expression data was not available. My program works great (Finding standard deviations, averages etc.) when I fill the empty cells with 0, but when I leave them blank I get the following error:
Resistance.append(map(float, row[4:]))
ValueError: could not convert string to float:
Basically when I try to append the data to a new array and convert it to floats I get the error because of the blank cells. If I don't do the float function, I get errors everywhere in the programd because I can't do the Stdev, for example I will have the following error:
withinA1 = numpy.std(a1)
File "C:\Python27\lib\site-packages\numpy\core\fromnumeric.py", line 2433, in std
return _wrapit(a, 'std', axis, dtype, out, ddof)
File "C:\Python27\lib\site-packages\numpy\core\fromnumeric.py", line 37, in _wrapit
result = getattr(asarray(obj),method)(*args, **kwds)
TypeError: cannot perform reduce with flexible type
How can I read through and tell python that the empty cells should just be skipped over? I've tried:
for label in Reader:
while i < len(label):
# if either the item in col1 or col2 is empty remove both of them
if label[i] == '':
del label[i]
# otherwise, increment the index
else:
i += 1
if len(label) == 0 or label[j] == '':
continue
else:
Resistance.append(map(float, label[4:]))
i += 1
and:
for row in Reader:
if len(row) == 0 or row[i] == '':
i+=1
continue
else:
Resistance.append(map(float, row[4:]))
i+=1
To no avail. Any help would be greatly appreciated, thank you.