Python IndexError: too many indices for array when trying to append two csv files
<p>I keep getting this error whenever I try to append two csv files together.</p>

<pre><code>log1 = np.genfromtxt('log40a.csv', dtype = float, delimiter=',', skip_header =1)
log2 = np.genfromtxt('log40b.csv', dtype = float, delimiter=',', skip_header= 1)
data = np.append(log1, log2)
</code></pre>

<p>This is the line the error I get on.</p>

<pre><code>mSec = data[:,0]
</code></pre>

<p>It works fine if I don't append both csv and I just plot the log1 file, but when I try to append them for some reason I the error:</p>

<pre><code>  File "&lt;ipython-input-5-6155c8de61ad&gt;", line 1, in &lt;module&gt;
    runfile('C:/Users/myname/.spyder2-py3/setdataexp.py', wdir='C:/Users/Myname/.spyder2-py3')

  File "C:\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
    execfile(filename, namespace)

  File "C:\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
    exec(compile(f.read(), filename, 'exec'), namespace)

  File "C:/Users/Myname/.spyder2-py3/setdataexp.py", line 11, in &lt;module&gt;
    mSec = data[:,0]

IndexError: too many indices for array
</code></pre>

<p>EDIT: I forgot to add a sample of the csv file</p>

<pre><code>mSec,speed,heading,gspeed,....
20,3.5,3,4.5
21,3,4,5
22,3.5,6,5.5
</code></pre>

<p>Giving the python documetation and you are using numpay you need to check this method for fusing existing arrays  <code>numpy.concatenate</code>
Ex taked from the docs: </p>

<pre><code>&gt;&gt;&gt; a = np.array([[1, 2], [3, 4]])
&gt;&gt;&gt; b = np.array([[5, 6]])
&gt;&gt;&gt; np.concatenate((a, b), axis=0)
array([[1, 2],
       [3, 4],
       [5, 6]])
</code></pre>

<p><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.concatenate.html" rel="nofollow">Documetation of numpay</a></p>

<p>And you have more methods to fusion your array:</p>

<ul>
<li><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.hstack.html" rel="nofollow">np.hstack</a></li>
<li><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.vstack.html" rel="nofollow">np.vstack</a></li>
<li><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.column_stack.html" rel="nofollow">np.column_stack</a></li>
<li><a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.ma.row_stack.html" rel="nofollow">np.row_stack</a></li>
</ul>

python