[SciPy-user] scikits.timeseries : Problem using tsfromtxt with converter

Pierre GM pgmdevlist@gmail....
Thu Jul 16 16:27:31 CDT 2009


On Jul 16, 2009, at 9:08 AM, Dharhas Pothina wrote:

> Hi,
>
> If I read it using
>
> data = ts.tsfromtxt(file,skiprows=1,datecols=(0),delimiter=',',freq  
> = 'H')
>
> ...
> I want to remove the 'mm' and read the data as floats. I tried using  
> a converter:
>
> conv = {1: lambda s: s.split('m')[0]}
> data = ts.tsfromtxt(file,skiprows=1,datecols=(0),delimiter=',',freq  
> = 'H',converters=conv)
>
> but then I get an error which seems to have something to do with the  
> date converter that was working in the earlier command:
>
> /usr/lib64/python2.5/site-packages/scikits.timeseries-0.91.1-py2.5- 
> linux-x86_64.egg/scikits/timeseries/extras.pyc in tsfromtxt(fname,  
> dtype, freq, comments, delimiter, skiprows, converters,  
> dateconverter, missing, missing_values, usecols, datecols, names,  
> excludelist, deletechars, case_sensitive, unpack, loose, asrecarray)
>    433     if len(dateinfo) == 1:
>    434         dateinfo = np.array(dateinfo[0], copy=False, ndmin=1)
> --> 435         dates = date_array([dateconv(args) for args in  
> dateinfo],
>    436                            freq=freq, autosort=False)
>    437     else:
>
> UnboundLocalError: local variable 'dateconv' referenced before  
> assignment
>
> What am I doing wrong?

Nothing. It's a bug, sorry about that. I'll try to correct that later  
today or tmw at worst.

Thanks for reporting,
Cheers
P.


More information about the SciPy-user mailing list