

def export_fromGDB():
    df1 = pd.read_csv("../data/exportFind_tenderee.csv",encoding="GBK")
    l_t = []
    for name,tenderee in zip(df1["name"],df1["tenderee"]):
        if tenderee is not None and tenderee!="":
            list_ten = list(set(tenderee[2:-2].split("', '")))
            l_t.append(list_ten)
        else:
            l_t.append([])
    df1["tenderer_count"] = l_t
    df1.to_csv("../data/exportFind_tenderee2.csv",columns=["name","tenderer_count"])
    return

    import gremlin_python
    df = pd.read_excel("../data/findTenderee.xlsx")
    set_win_tenderer = set()
    for item in df["µ¥Î»Ãû³Æ"]:
        if item is not None and item !="":
            set_win_tenderer.add(item)

    df1 = pd.read_csv("../data/exportFind_tenderee.csv",encoding="GBK")

    task_queue = queue.Queue()
    for _name in list(set_win_tenderer-set(df1["name"])):
        task_queue.put(_name)
    result_queue = queue.Queue()

    def _handle(_name,result_queue,pool_gdb):
        client = pool_gdb.getConnector()
        callback = client.submitAsync("g.V('%s').outE('ZhongBiaoRelation').inV().inE('ZhaoBiaoRelation').outV()"%(_name))
        list_tenderee = []
        for result in callback.result():
            for item in result:
                list_tenderee.append(item.id)
        result_queue.put({"name":_name,"tenderee":list_tenderee})
        pool_gdb.putConnector(client)

    pool_gdb = ConnectorPool(init_num=30,max_num=50,method_init=getConnect_gdb)
    mt = MultiThreadHandler(task_queue=task_queue,task_handler=_handle,result_queue=result_queue,thread_count=50,pool_gdb=pool_gdb)
    mt.run()

    df_data = {"name":[],"tenderee":[]}
    while(True):
        try:
            item = result_queue.get(block=True,timeout=1)
            for _k in df_data.keys():
                if _k in item:
                    df_data[_k].append(str(item[_k]))
                else:
                    df_data[_k].append("")
        except queue.Empty as e:
            break
        except Exception as e:
            traceback.print_exc()

    df = pd.DataFrame(df_data)
    df.to_csv("../data/exportFind_tenderee1.csv",columns=["name","tenderee"])