Hello,
I have a problem with a list written in a DAT.
If I write a list in a DAT cell, when I read it, I cannot extract an item in the list
here is the script:
liste = [0,13,15,23]
print (liste[2])
op(‘table1’)[0,0] = liste
liste2 = op(‘table1’)[0,0]
print(liste2)
print(liste2[2])
and the answer
python >>>
15
[0, 13, 15, 23]
Traceback (most recent call last):
File “</project1/text1:op(‘/project1/text1’).run()>”, line 1
td.Error: File “/project1/text1”, line 6
TypeError: ‘td.Cell’ object is not subscriptable
Results of run operation resulted in exception.
I need to be able to read it as a list to parse it on another tables.
Someone have a solution? Its 4 hours I am blocked on that, searching every possible way. I tried making a dictionary saved in operator with the same problem.
Thank you in advance!
Jacques
Thank you everybody. Ivan, your solution doesn’t work: TypeError: eval () arg 1 must be a string, bytes or code object.
Matthew, I found a similar solution during that time:
liste = [0,13,155,23]
print (liste[2])
op('table1')[0,0] = liste
liste2 = op('table1')[0,0]
liste2 = liste2.val
liste2 = liste2.split()
l = len(liste2)
liste3 = []
for i in range (0,l):
item = liste2[i]
if i == 0:
item = item[1:]
else:
item = item[0:]
item = item [:-1]
liste3.append(item)
print (int(liste3[2]))
listeDat.toe (3.6 KB)
I still hope for a more elegant solution…
Thank you
Ivan DelSol , I must give some explanation
We tag a bunch of video clip (and sub clip) in FinalCut Pro, exporting as XML
I import and parse the XML in TD, obtaining two list:
– the list of clips, name of the file, TC in and TC out, attached keywords
– the list of keywords with, for each clip, the list of attached clip. I have tried to put each clip number in different column but the task of retrieving it block the movie play. With list I can randomise it and parse it easily.
Ivan technic works with DAT but also with python dictionaries, opening great expectations.