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>Just remove <code>,0</code> and everything will work fine.</p>

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

<p>This traceback</p>



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

<p>said that it is a problem in your code.</p>

<p><strong>UPD:</strong></p>

<p><code>np.append</code> produce single dimensional array and it doesn't allow slicing operations, you have to modify append operation like this:</p>

<pre><code>data = np.append(log1, log2, axis=0)
</code></pre>

python