[Numpy-discussion] Fwd: np.loadtxt : yet a new implementation...

Pierre GM pgmdevlist@gmail....
Mon Dec 1 13:14:19 CST 2008

(Sorry about that, I pressed "Reply" instead of "Reply all". Not my  
day for emails...)

> On Dec 1, 2008, at 1:54 PM, John Hunter wrote:
>> It looks like I am doing something wrong -- trying to parse a CSV  
>> file
>> with dates formatted like '2008-10-14', with::
>>   import datetime, sys
>>   import dateutil.parser
>>   StringConverter.upgrade_mapper(dateutil.parser.parse,
>> default=datetime.date(1900,1,1))
>>   r = loadtxt(sys.argv[1], delimiter=',', names=True)
> John,
> The problem you have is that the default dtype is 'float' (for  
> backwards compatibility w/ the original np.loadtxt). What you want  
> is to automatically change the dtype according to the content of  
> your file: you should use dtype=None
> r = loadtxt(sys.argv[1], delimiter=',', names=True, dtype=None)
> As you'll want a recarray, we could make a np.records.loadtxt  
> function where dtype=None would be the default...

More information about the Numpy-discussion mailing list