码迷,mamicode.com
首页 > 编程语言 > 详细

预处理算法_2_类型转换

时间:2021-03-04 13:15:00      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:数据   tar   预处理   The   ams   tput   target   dict   file   

 

# <editable>


def execute(conn, inputs, params, outputs, reportFileName):
    # <editable>
    ‘‘‘
    载入模块
    ‘‘‘
    import sqlalchemy
    import db_utils

    ‘‘‘
    选择目标数据
    ‘‘‘
    data_in = db_utils.query(conn, ‘select ‘ + params[‘columns‘] + ‘ from ‘ + inputs[‘data_in‘])

    ‘‘‘
    列名为键,类型为值的字典
    ‘‘‘
    modifi_type = params[‘modifi_type‘]
    type_dict = {}
    for i in eval(modifi_type):
        if i[‘targetType‘] == ‘numeric‘:
            type_dict[i[‘origName‘]] = eval((‘sqlalchemy.types.NUMERIC‘ + ‘(255,‘ + str(i[‘otherParam‘]) + ‘)‘))
        elif i[‘targetType‘] == ‘text‘:
            type_dict[i[‘origName‘]] = sqlalchemy.types.Text
        elif i[‘targetType‘] == ‘date‘:
            type_dict[i[‘origName‘]] = sqlalchemy.types.Date
        else:
            type_dict[i[‘origName‘]] = sqlalchemy.types.TIMESTAMP

    # 写出数据
    db_utils.modifyType(conn, outputs[‘data_out‘], data_in, type_dict)
# </editable>

 

预处理算法_2_类型转换

标签:数据   tar   预处理   The   ams   tput   target   dict   file   

原文地址:https://www.cnblogs.com/renfanzi/p/14476408.html

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!