from numpy import NaN
import pandas as pd
import json
import re
src=pd.read_excel("第五批.xls")
alg_result=src['alg_result'].values.tolist()
src_density_typeO=src['src_density_type'].values.tolist()

focus=[]
tools=[]
diy=[]
filetype=[]
cnt=[]
series_id=[]
src_density_type=[]
for i,txt in enumerate(alg_result):
    if alg_result[i]!=alg_result[i]:
        continue
    if src_density_typeO[i]==20:
        src_density_type.append('')
    else:
        src_density_type.append(src_density_typeO[i])
    focus.append("ANNO3")
    tools.append("CUBOID")
    diy.append("")
    filetype.append("")
    text=json.loads(txt)
    srcBbox=text["srcBbox"]
    srcHU_values_path=text['srcNodule_mask_path']
    if srcHU_values_path=="":
        srcHU_values_path=text['srcHU_values_path']
    re1 = r'shjss-aitrox/(.*?)_NODULE'
    reResult = re.findall(re1, srcHU_values_path)
    print(reResult)
    studyid,seriesid=reResult[0].split('/')
    series_id.append(seriesid)
    tmp="{\"lesionId\":0,\"position\":"+str(srcBbox)+"}"
    cnt.append(tmp)

    
output=pd.DataFrame({"序列号":series_id,"病灶":focus,"影像工具":tools,"影像结果":cnt,"自定义内容":diy,"文件类型":filetype,"肺结节类型":src_density_type})
output.to_csv("第五批output.csv",index=False,encoding="utf_8_sig")
    
