コード例 #1
0
def read_from_start(date_start):
    dir_pre = '/data_ssd/work_data/liqin/user_log/clean/'
    dir_suf = '.user_feedback'

    #date_start = '20150916'
    date_start_sturct = datetime.datetime.strptime(date_start, '%Y%m%d')
    date_now_struct = date_start_sturct

    date_today_struct = datetime.datetime.today()
    today_str = date_to_str(date_today_struct)

    datedelta = datetime.timedelta(days=1)

    date_yesterday = date_today_struct - datedelta
    date_yesterday_str = date_to_str(date_yesterday)

    user_follow_dict = {}

    date_now_read = date_start
    conn, cursor = connect_mysql(MYSQL_TABLE)
    while date_now_read != today_str:
        read_file = dir_pre + date_now_read + '/' + date_now_read + dir_suf
        print 'read_file_now : ', read_file
        try:
            read_from_cleandata(user_follow_dict, read_file, cursor)
        except IOError:
            break
        date_now_struct += datedelta
        date_now_read = date_to_str(date_now_struct)

    to_txt(date_yesterday_str, user_follow_dict)
    close_mysql(conn)
    return user_follow_dict
コード例 #2
0
def read_from_start(date_start):
    dir_pre = '/data_ssd/work_data/liqin/user_log/clean/'
    dir_suf = '.user_feedback'

    #date_start = '20150916'
    date_start_sturct = datetime.datetime.strptime(date_start,'%Y%m%d')
    date_now_struct = date_start_sturct


    date_today_struct = datetime.datetime.today()
    today_str = date_to_str(date_today_struct)

    datedelta =  datetime.timedelta(days = 1)

    date_yesterday = date_today_struct -datedelta
    date_yesterday_str = date_to_str(date_yesterday)

    user_follow_dict = {}

    date_now_read = date_start
    conn, cursor = connect_mysql(MYSQL_TABLE)
    while date_now_read != today_str:
        read_file = dir_pre + date_now_read+'/'+date_now_read +dir_suf
        print 'read_file_now : ',read_file
        try:
            read_from_cleandata(user_follow_dict, read_file, cursor)
        except IOError:
            break
        date_now_struct += datedelta
        date_now_read = date_to_str(date_now_struct)

    to_txt(date_yesterday_str, user_follow_dict)
    close_mysql(conn)
    return user_follow_dict
コード例 #3
0
def update_today(user_follow_dict):

    dir_pre = '/data_ssd/work_data/liqin/user_log/clean/'
    dir_suf = '.user_feedback'

    date_today_struct = datetime.datetime.today()
    today_str = date_to_str(date_today_struct)

    datedelta = datetime.timedelta(days=1)
    datedelta_2 = datetime.timedelta(days=2)

    date_prev_dict = date_today_struct - datedelta_2
    date_prev_dict_str = date_to_str(date_prev_dict)
    user_follow_dict = read_from_txt(date_prev_dict_str)

    date_yesterday = date_today_struct - datedelta
    date_yesterday_str = date_to_str(date_yesterday)
    read_file = dir_pre + date_yesterday_str + '/' + date_yesterday_str + dir_suf

    conn, cursor = connect_mysql(MYSQL_TABLE)
    print 'read_file_now : ', read_file
    try:
        read_from_cleandata(user_follow_dict, read_file, cursor)
    except IOError:
        pass

    to_txt(date_yesterday_str, user_follow_dict)
    close_mysql(conn)
    return user_follow_dict
コード例 #4
0
def update_today(user_follow_dict):

    dir_pre = '/data_ssd/work_data/liqin/user_log/clean/'
    dir_suf = '.user_feedback'

    date_today_struct = datetime.datetime.today()
    today_str = date_to_str(date_today_struct)

    datedelta =  datetime.timedelta(days = 1)
    datedelta_2 =  datetime.timedelta(days = 2)

    date_prev_dict = date_today_struct -datedelta_2
    date_prev_dict_str = date_to_str(date_prev_dict)
    user_follow_dict = read_from_txt(date_prev_dict_str)

    date_yesterday = date_today_struct -datedelta
    date_yesterday_str = date_to_str(date_yesterday)
    read_file = dir_pre + date_yesterday_str+'/'+date_yesterday_str +dir_suf

    conn, cursor = connect_mysql(MYSQL_TABLE)
    print 'read_file_now : ',read_file
    try:
        read_from_cleandata(user_follow_dict, read_file, cursor)
    except IOError:
        pass
    
    to_txt(date_yesterday_str, user_follow_dict)
    close_mysql(conn)
    return user_follow_dict