from db import paients_calculated
from logger import logger

def main():
    'main entry'
    from datetime import datetime
    start = datetime.now()
    logger.info('hello..')
    toCsv()

    print('Elapsed time: ', datetime.now() - start)

def toCsv():
    header = '序号,姓名,住院号,入科年龄,入科日期,入科天数,日期,体重,EN,PN,其他\n'
    p_info = '{0},{1},{2},{3},{4},,,,,,{5}\n'
    daily_info = ',,,,,{0},{1},{2},{3},{4},\n'
    counter = 1
    for p in paients_calculated.find():
        print(p)
        a= p_info.format(counter,p['info'][2],p['_id'],p['info'][5],p['info'][7],'#'.join(p['info']))
        
        print(a)
        counter += 1
        break

if __name__ == '__main__':
    main()
@@ -57,71 +57,67 @@
 ger%0A
-%0Adef main():%0A    'main entry'%0A    from datetime import datetime
+from datetime import datetime%0A%0Adef main():%0A    'main entry'
 %0A   
@@ -477,17 +477,20 @@
         
-a
+info
 = p_info
@@ -586,60 +586,1174 @@
     
-%0A        print(a)%0A        counter += 1%0A        break
+nu_counter = 0%0A        len_nu = len(p%5B'nu'%5D)%0A        while nu_counter %3C len_nu:%0A            nu = p%5B'nu'%5D%5Bnu_counter%5D%0A            date_nu = nu%5B'd'%5D%0A            en_nu,pn_nu = 0,0%0A%0A            if nu%5B'en'%5D:%0A                en_nu = nu%5B'v'%5D%0A            else:%0A                pn_nu = nu%5B'v'%5D%0A            if (nu_counter %3C len_nu - 1):%0A                next_nu = p%5B'nu'%5D%5Bnu_counter+1%5D%0A                if next_nu%5B'd'%5D == date_nu:%0A                    if next_nu%5B'en'%5D:%0A                        en_nu = next_nu%5B'v'%5D%0A                    else:%0A                        pn_nu = next_nu%5B'v'%5D%0A                    nu_counter += 1%0A            nu_counter += 1%0A            wight = _get_wight(p, date_nu)%0A%0A            one_nu = daily_info.format(_total_days(p, date_nu), date_nu,wight,en_nu,pn_nu)%0A            print(one_nu)%0A        print(info)%0A        counter += 1%0A        break%0A%0Adef _get_wight(p, date_nu):%0A    wight = 0%0A    for w in p%5B'wt'%5D:%0A        if date_nu %3E w%5B'st'%5D:%0A            wight = w%5B'w'%5D%0A        else:%0A            break%0A    return wight%0A%0Adef _total_days(p, date_nu):%0A    return (datetime.strptime(date_nu,'%25Y-%25m-%25d')-datetime.strptime(p%5B'info'%5D%5B7%5D.split(' ')%5B0%5D,'%25Y-%25m-%25d')).days
 %0A%0Aif

parsed one person