I need to read in a large amount of data from a csv file into arrays. I am using Numpy as I need to later manipulate and plot the results. I have decided to use numpy.loadtxt as this appears to be the most efficient method to read in the data. I can read the data into one big string array but I am struggling to convert the data as I read it in.
Here is the code I am using...
# -*- coding: utf-8 -*-
"""
Created on Sat Nov 21 21:41:05 2009
@author: Roger Iles
"""
import numpy as np
test=np.loadtxt('data_dev_test.csv',delimiter=',', unpack=True,
dtype={'names':('localtime','localdate','elapsedtime','dose','units'),
'formats': ('s8','s7','s10','.3f','s2')})
print test
And the data has the format...
11:16:29, 24NOV00, 0000:00:00,1.087,nG
11:17:34, 24NOV00, 0000:01:04,1.087,nG
On running the code I get the following error...
Traceback (most recent call last):
File "C:\Python26\Lib\site-packages\xy\tepc.py", line 11, in <module>
'formats': ('s8','s7','s10','.4f','s2')})
File "C:\Python26\lib\site-packages\numpy\lib\io.py", line 443, in loadtxt
dtype = np.dtype(dtype)
TypeError: data type not understood
I'd really appreciate any assistance here as I am farily new to Python and do not know where to go next.
Many thanks in advance,
RogerI