有没有办法在python脚本中遍历Orange表?

2024-05-19 07:42:35 发布

您现在位置:Python中文网/ 问答频道 /正文

下面是将图像导入到Orange的代码,导入的图像列表存储在Orange表中:

import Orange
from orangecontrib.imageanalytics.import_images import ImportImages
import_images = ImportImages()
data, err = import_images("E:/CME/CME3/Project Work/domestic-animals")    
if data:
    print(data)
    print(err)
    print(type(data))

导入的图像作为表存储在数据变量中

输出:

>>> 
Running script:
[[] {calf, calf.png, 45538, 191, 152},
 [] {cat, cat.png, 22193, 105, 137},
 [] {chick, chick.png, 14891, 85, 92},
 [] {cow, cow.png, 62159, 210, 189},
 [] {crow, crow.jpg, 6778, 259, 194},
 [] {dog, dog.png, 28745, 129, 125},
 [] {duck, duck.png, 39583, 158, 172},
 [] {duckling, duckling.png, 17109, 99, 119},
 [] {foal, foal.png, 39210, 147, 177},
 [] {goat, goat.png, 53039, 221, 179},
 [] {goose, goose.png, 34442, 141, 202},
 [] {hen, hen.png, 41716, 134, 168},
 [] {horse, horse.png, 69109, 285, 195},
 [] {kid, kid.png, 36290, 170, 160},
 [] {lamb, lamb.png, 35520, 123, 168},
 [] {Milka, Milka.jpg, 111090, 533, 800},
 [] {ox, ox.png, 56401, 191, 189},
 [] {rabbit, rabbit.png, 24294, 97, 174},
 [] {rooster, rooster.png, 41518, 145, 180},
 [] {sheep, sheep.png, 58022, 214, 181},
 [] {turkey, turkey.png, 55072, 171, 182}]
0
<class 'Orange.data.table.Table'>
>>> 

数据变量的类型为Table。 我想访问.png文件的列。如何遍历上表? 我尝试使用for循环进行迭代:

for i in range(len(data)):
    files = data[i][1]

但我有一个错误:

IndexError: index 1 is out of bounds for axis 0 with size 0

先谢谢你


Tags: 数据图像importfordatachickpngcat

热门问题