Recursive csv import functions for Pandas

MRAB python at mrabarnett.plus.com
Tue Aug 2 13:08:43 EDT 2016


On 2016-08-02 10:50, andrea.botti at gmail.com wrote:
> I have put together the following code:
>
[snip]
>     		while csvnameR[12:18] == csvnameT[12:18]:
>     			print csvR + "=" + csvT
>     			
>     			r.to_csv('./output_csv/'+ csvR +'.csv')
>     		
>     			hdh = r.sub(t,axis=0).dropna()
>     			hdh[hdh['temp']<=1] = 0
>     			csvHDH = csvnameT[12:18]
>     			hdh_week = hdh.temp.resample('W-MON').sum().round(decimals=0)
>     			hdh_week.to_csv('./output_csv/HDH/' + csvHDH + '_HDH.csv')
>
> The sequence of action should be:
> for A08_KI
>  - import A08_KI_T1,T2,...Tn, merge them into A08_KI_T and resample them by the hour (room temp.)
>  - import A08_KI_R1,R2,...Rn, merge them into A08_KI_R and resample them by the hour (radiator temp.)
>  - every time XX_XX_R = XX_XX_T (i.e. A08_KI_T and A08_KI_R, or A10_LR_T and A10_LR_R) calculate HDH = R - T.
>
> The code I developed has something wrong and the command:
>
>     while csvnameR[12:18] == csvnameT[12:18]:
> seems to cause the loop to go on for ever.
>
Look at the body of that loop. Nowhere in it do you change the value of 
'csvnameR' or 'csvnameT', so if the condition was true initially, it'll 
still be true the next time round, and forever more.



More information about the Python-list mailing list