maxArch
February 21, 2017, 10:16pm
1
Hello all !
I need a other advise in python in touch
in my table i have a name of movie file, let say it call 003_blablabla_1.mov
i get it by my op(‘table_movie’)[1,1]
my final goal is to only get the ‘1’ of my movie name and sen it to a channel of a other op(‘name’)
I know it not working, but this is how i will do it from what i know of python.
A = op('table_movie')[1,1]
B = A[-5:]
C= B[1:]
op('name').par.value0 = C
Is there a place where i can find string modification in touch and how to use it
or let me know if you know the good way
raganmd
February 21, 2017, 10:26pm
2
A = op('table_movie')[1,1]
That’s likely going to retrieve a cell object for you. If you want the contents of the cell you should add .val to the end of your reference:
A = op('table_movie')[1,1].val
You might check the official Python documentation if you want more information about working with Strings in python:
[url]https://docs.python.org/3.4/library/string.html[/url]
Additionally, you might consider numbering your files with a leading 0, for example:
003_blablabla_01.mov
This limits the portion of the file that you need to know about. With this in mind you can get the two digits with:
op( 'table2' )[ 0,0 ].val[ -6:-4 ]
I know it a long time, but I am still struggling with that…
[code]rowCheck = op( ‘null_Video_now’ )[‘v1’]
print (rowCheck)
print (op(‘Play_LIST_BACKGROUND’)[rowCheck,0])
print (op(‘Play_LIST_BACKGROUND’)[1,0])
EX = op(‘Play_LIST_BACKGROUND’)[1,0].val[ -6:-4 ]
print (EX)
numberString = op(‘Play_LIST_BACKGROUND’)[rowCheck,0].val[ -6:-4 ]
print (numberString)[/code]
Textport
python >>>
1
None
001_bird_fulsize_2_0.mov
_0
Traceback (most recent call last):
File "/kantanmapper/text3", line 9, in <module>
AttributeError: 'NoneType' object has no attribute 'val'
python >>>
EX (no variable) is the same as numberString ( with variable )
I should have the same resul. But I get ‘NoneType’ object has no attribute ‘val’
What is my mistake and why it not working?
I’m seeing in your print that
print (op('Play_LIST_BACKGROUND')[rowCheck,0])
is returning
None
It looks like rowCheck is a CHOP maybe?
rowCheck = op( 'null_Video_now' )['v1']
With a none returned like this it seems like maybe ‘v1’ isn’t the name of an actual channel in that op? If you can post a simplified example it’ll be easier to help push you in the right direction.
rowCheck = op( 'null_Video_now' )['v1']
print (rowCheck)
python >>>
1
python >>>
if i just print rowCheck i get 1
i try to make a sample exemple soon .
thanks
ahhhhh!
Sorry about that I was reading a row behind.
Channels are lists of floats, so you might try:
int( op( 'null_Video_now' )['v1'].vals )
To get an integer out of this.
Thanks it help
the op ( ‘null_Video_now’) was a null chop. I was able to get it by removing the .val
[code]rowCheck = int( op( ‘null_Video_now’ )[‘v1’] )
print (rowCheck)
numberString = op(‘Play_LIST_BACKGROUND’)[rowCheck,0].val[ -5:-4 ]
print (numberString)[/code]
python >>>
1
0
python >>>