import pandas as pd
import time
def makeurl(url,url_show):
    return '=HYPERLINK("{}","{}")'.format(url,  url_show)

def handle_df_gmgn_pump_total():
    df = pd.read_csv("./df_gmgn_pump_total.csv")
    # token_url,token_name,age,mc,holders
    
    df['datetime'] = pd.to_datetime(df['save_timestamp'],unit='ms' )
    df=df.sort_values(by=['datetime','token_url'],ascending=[True,True])
    df = df.drop_duplicates(subset=['token_url'],keep='first')
    
    df['datetime'] =df['datetime'].dt.tz_localize('UTC').dt.tz_convert('Asia/Shanghai').dt.strftime('%Y-%m-%d %H:%M:%S')
    
    
    df['token_add'] = df['token_url'].str.split('/').str[-1]
    
 
 
    df["gmgn"] = df.apply(lambda ser: makeurl(
    f"https://gmgn.ai/sol/token/{ser['token_add']}" , "gmgn" ), axis=1)

    df["defined"] = df.apply(lambda ser: makeurl(
     f"https://www.defined.fi/sol/{ser['token_add']}" , "defined" ), axis=1)
    df["isnormal"] = None
    df["hassec"] = None
    df["beizhu"] = None
    df.to_excel(f"df_gmgn_pump_total_{int(time.time())}.xlsx",index=False)



handle_df_gmgn_pump_total()