Reputation: 11
I am trying to use the row values to get the C_vel
values.
The code:
wb = op.load_workbook('Canopy\Scripts\De Velliers.xlsx')
ws = wb ['Sheet1']
for row in ws.rows:
for cell in row:
print(cell.value)
print "----------"
C_vel = ws.rows / (A_c * rho)
print "C_vel: ", C_vel
The error message:
TypeError
Traceback (most recent call last)
C:\Users\Fraixxer Fraiz\Canopy\scripts\franis 1.py in <module>()
26 print(cell.value)
27 print "----------"
---> 28 C_vel = ws.rows / (A_c * rho)
29 print "C_vel: ", C_vel
30
TypeError: unsupported operand type(s) for /: 'tuple' and 'float'
Upvotes: 0
Views: 1747
Reputation: 1327
You can not do mathematical operations on tuples. Using numpy you could convert the tuple to an array first. Mathematical operations can be performed on numpy arrays.
import numpy as np
wb = op. load _ workbook ('Canopy\Scripts\De Velliers.xlsx')
ws = wb ['Sheet1']
for row in ws . rows:
for cell in row:
print(cell. value)
print "----------"
C_vel = np.array(ws. rows)/ (A_c * rho)
print "C_vel:",C_vel
Upvotes: 1