I posted this question because I was wondering whether I did something terribly wrong to get this result.
I have a medium-size csv file and I tried to use numpy to l
FWIW the built-in csv module works great and really is not that verbose.
csv module:
%%timeit
with open('test.csv', 'r') as f:
np.array([l for l in csv.reader(f)])
1 loop, best of 3: 1.62 s per loop
np.loadtext
:
%timeit np.loadtxt('test.csv', delimiter=',')
1 loop, best of 3: 16.6 s per loop
pd.read_csv
:
%timeit pd.read_csv('test.csv', header=None).values
1 loop, best of 3: 663 ms per loop
Personally I like using pandas read_csv
but the csv module is nice when I'm using pure numpy.