如何确定源目标的列名?

时间:2018-09-13 17:36:29

标签: ssis

我正在尝试将excel工作表加载到数据库中,可以说excel工作表中只有一个列名为NAME,该列映射到数据库中的NAME。但是有时候,我会得到一个带有Name列的excel工作表,因为它区分大小写,所以会引发错误。有没有办法大写列名或有第二个映射?处理此问题的最佳方法是什么?

1 个答案:

答案 0 :(得分:0)

因为我很好奇它的外观,所以我在python中进行了测试:

import datetime, time
name_dict = ['name','Name','NAME','NAMe','NAme','NamE','NaME']
name = 'Name'
z=0
x=0

for z in range(0,5):    
    start= time.time()
    for x in range(1,10000000):
        if name_dict[2].upper() == "NAME":
            None
    stop=time.time()    
    print('Try no. '+str(z)+' Upper test:'+str(stop-start))

for z in range(0,5):
    start= time.time()
    for x in range(1,10000000):
        if name in name_dict:
            None
    stop=time.time()
    print('Try no. '+str(z)+' Search in dict test:'+str(stop-start))

结果

Try no. 0 Upper test:1.3549904823303223
Try no. 1 Upper test:1.356055736541748
Try no. 2 Upper test:1.3510148525238037
Try no. 3 Upper test:1.3499987125396729
Try no. 4 Upper test:1.3550000190734863
Try no. 0 Search in dict test:0.7339987754821777
Try no. 1 Search in dict test:0.738067626953125
Try no. 2 Search in dict test:0.7309765815734863
Try no. 3 Search in dict test:0.7490558624267578
Try no. 4 Search in dict test:0.7480108737945557

在python中,字典搜索速度更快。