Reputation: 9062
Data
HOD,2012-1-3,1,5000
HOD,2012-1-4,1,5000
HOD,2012-1-5,1,5000
HOD,2012-1-6,1,5000
HOD,2012-1-9,1,5000
HOD,2012-1-10,1,5000
myData = np.genfromtxt(inputFile, dtype=[('Symbol',str),('Date', 'datetime64[D]'),('Value', int),('Allocation', long)], delimiter=',')
print myData
Output
('', datetime.datetime(1969, 12, 31, 0, 0), 1, 5000L)
('', datetime.datetime(1969, 12, 31, 0, 0), 1, 5000L)
('', datetime.datetime(1969, 12, 31, 0, 0), 1, 5000L)
('', datetime.datetime(1969, 12, 31, 0, 0), 1, 5000L)
('', datetime.datetime(1969, 12, 31, 0, 0), 1, 5000L)
Why are my strings lost?
Upvotes: 1
Views: 113
Reputation: 369244
String dtype require you to specify length:
dtype=[('Symbol', 'S3'), ...]
or
dtype=[('Symbol', (str, 3)), ...]
If you want arbitrary-length string, specify object
as a type; it will allow any object to be assigned.
Upvotes: 1