Esempio n. 1
0
def getBusinessNameFromSql():
    words = []
    type = "_业务名称"
    sql = """
    select distinct F002 from stk039
    where isvalid = '1'
    and f001 = '2'
    """
    data = getData(sql)
    if data is None:
        failExit("access postgresql error!")
    for item in data:
        if item.find('(') < 0 and item.find('(') < 0:
            for subProduct in re.split(",|,|;|;|、", item):
                words.append(subProduct.strip())
                #print subProduct.strip()
        else:
            words.append(item.strip())
            #print item.strip()


    sql = """
    select distinct products from
    (
      select f001V_stk219 as products, 
                   t1.declaredate_stk219 as valid_date,
                                max(t1.declaredate_stk219) over (partition by t1.orgid_stk219) as latest
                                    from STK219 t1 join stk001 t2 on t2.comcode = t1.ORGID_STK219 
                                    where t1.isvalid = 1 and t2.isvalid = 1 and f001V_stk219 not like '%B、C、D%'
    ) t where valid_date = latest """

    data = getData(sql)
    if data is None:
        failExit("access postgresql error!")
    for item in data:
        item = item.replace('  ', '')
        item = item.replace('  ', '')
        if item.find('(') < 0 and item.find('(') < 0:
            for product in re.split(",|,|;|;|、", item):
                words.append(product.strip())
                #print product.strip()
        else:
            for product in item.strip().split('、'):
                if product.find('(') < 0 and product.find('(') < 0:
                    for subProduct in re.split(",|,|;|;|、", product):
                        words.append(subProduct.strip())
                        #print subProduct.strip()
                else:
                    words.append(product.strip())
                    #print product.strip()
                 
    new_data = []                    
    for item in words:
        if item != "" and not isDigit(item.lower()):
             new_data.append(GetOneDictLine.getOneDictLine(item,type)) 
    return new_data
Esempio n. 2
0
def getAnalystName():
    new_data = []
    type="_分析师姓名"
    sql = """
    select distinct t.f003v_yb002 from yb002 t where t.f003v_yb002 != ''
    """
    data = getData(sql)
    if data is None:
        failExit("access postgresql error!")        
    for line in data:
        new_data.append(GetOneDictLine.getOneDictLine(line,type));  
    return new_data
def changeToDictLine(dictType,data,from_where):
    new_data=[]
    for line in data:
        cols = line.split('\t')
        id = ''
        for col in cols:
            if(col == cols[0]):
                id = col
                if dictType=="_上证a股代码" or dictType=="_深证a股代码":
                    new_data.append(GetOneDictLine.getOneDictLineWithId(col,dictType,cols[0],""));
                continue
            elif(col != ''):
                if(id != ''):
                    new_data.append(GetOneDictLine.getOneDictLineWithId(col,dictType,id,from_where));  
                else:
                    new_data.append(GetOneDictLine.getOneDictLine(col,dictType,from_where));     
    return new_data