using python to read a column vector from excel
<p>OK i think this must be a super simple thing to do, but i keep getting index error messages no matter how i try to format this.  my professor is making us multiply a 1X3 row vector by a 3x1 column vector, and i cant get python to read the column vector.  the row vector is from cells A1-C1, and the column vector is from cells A3-A5 in my excel spreadsheet.  I am using the right "format" for how he wants us to do it, (if i do something that works, but don't format it the way he likes i don't get credit.)  the row vector is reading properly in the variable explorer, but i am only getting a 2x2 column vector (with the first column being the 0th column and being all zeros, again how he wants it), I havent even gotten to the multiplication part of the code because i cant get python to read the column vector correctly. here is the code:</p>

<pre><code>import xlwings as xw
import numpy as np

filename = 'C:\\python\\homework4.xlsm'
wb=xw.Workbook(filename)

#initialize vectors
a = np.zeros((1+1,3+1))
b = np.zeros((3+1,1+1))

n=3

#Read a and b vectors from excel
for i in range(1,n+1):
    for j in range(1,n+1):
        a[i,j] = xw.Range((i,j)).value
    'end j'
    b[i,j] = xw.Range((i+2,j)).value
'end i'
</code></pre>

<p>Something like this should work. The way you iterate over <code>i</code> and <code>j</code> are wrong (plus the initalization of <code>a</code> and <code>b</code>)</p>

<pre><code>  #initialize vectors
a = np.zeros((1,3))
b = np.zeros((3,1))

n=3

#Read a and b vectors from excel
for i in range(0,n):
    a[0,i] = xw.Range((1,i+1)).value
for i in range (0,n)
    b[i,0] = xw.Range((3+i,1)).value
</code></pre>

python excel vector