zoukankan      html  css  js  c++  java
  • 处理idl文件

    将如下格式的数据:

    {“60091.jpg”: [[214.1664, 192.99996, 261.00032, 224.83332000000001, 1], [74.83328, 160.49988, 224.0, 267.4998, 1]]}
    {“60092.jpg”: [[15.166656, 197.49996, 80.16640000000001, 233.49996000000002, 1], [52.250048, 215.49996, 85.49951999999999, 254.5002, 3]]}
    {“60093.jpg”: []}
    {“60094.jpg”: [[171.33312, 188.49996000000002, 243.8336, 240.66647999999998, 1]]}
    {“60095.jpg”: []}
    {“60096.jpg”: []}
    {“60097.jpg”: []}
    转换为
    000002.jpg dog 44 28 132 121
    000002.jpg cat 46 18 112 123
    000003.jpg ggg 54 19 243 178
    进而实用工具转换为xml格式,实现可视化

    1. import pandas as pd
    2. import csv
    3. label=open('label.idl','r')
    4. label_list=label.readlines()
    5. #fo = open("foo.txt", "wb")
    6. output_file ='./foo.txt'
    7. output = open(output_file,'wb')
    8. writer = csv.writer(output)
    9. temp=[]#pre define tuple or list is ok
    10. for content in label_list:
    11. obj=pd.read_json(content,orient='index')
    12. (row,col)=obj.shape
    13. for i in range(col):
    14. temp=[obj.ix[0].name,obj.ix[0][i][4],obj.ix[0][i][0],obj.ix[0][i][1],obj.ix[0][i][2],obj.ix[0][i][3]]
    15. writer.writerow(temp)
    16. # writer.writerow(obj)
    17. # writer.writerow([obj.index,obj[i][0]])
    18. # writer.writerow(obj[i][0])
    19. # output.writelines(str(obj[i]))
    20. # output.write(str(obj[i]))
    21. # fo.write(str(obj[1][0][0]))
    22. # fo.write(str(obj[1][0][0]);
    23. #
    24. # obj[1][0][0]
    25. # obj[1][0][1]
    26. # obj[1][0][2]
    27. # obj[1][0][3]
    28. # obj[1][0][4]
    29. # i++
    30. #obj[]
    31. #print obj[0][]
    32. #(obj[0].to_str()).split(',')[4]
    33. output.close()
    34. label.close()



    keep calm and carry on
  • 相关阅读:
    mysql命令集锦
    linux 删除文件名带括号的文件
    linux下的cron定时任务
    struts2文件下载的实现
    贴一贴自己写的文件监控代码python
    Service Unavailable on IIS6 Win2003 x64
    'style.cssText' is null or not an object
    "the current fsmo could not be contacted" when change rid role
    远程激活程序
    新浪图片病毒
  • 原文地址:https://www.cnblogs.com/geekvc/p/6147046.html
Copyright © 2011-2022 走看看