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'
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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.