There are a bunch of very similar issues on StackOverflow [post 1], [post 2].
For your reference, there is a much cleaner way of achieving this.
genfromtxt
will suit your requirements pretty well. From the documentation,
Load data from a text file, with missing values handled as specified.
Each line past the first skip_header lines is split at the delimiter
character, and characters following the comments character are
discarded.
You would need to do something like this.
from numpy import genfromtxt
my_data = genfromtxt('activity(delimited)', delimiter=',')
Given that yours is a csv, the delimiter is a ,
.
my_data
should now hold a numpy ndarray
.