text parsing

Jun 14, 2007 at 6:10pm

text parsing

Allo!
Just looking for some advice on text file parsing. From experience, what’s the most efficient way to parse a string like the following:

tx,183.16806,ty,199.03603,tz,164.23111,ox,0.00000,oy,0.00000,oz,-0.72368

Any advice would be hugely appreciated!
Thanks

#32465
Jun 14, 2007 at 7:08pm

Clarification…. I’d like to isolate the value that comes after each tag (i.e tx, ty etc.). I’ve tried converting the string (or list) into a collection using the [Ltocoll] object. Then I used the “nth” message to pull out values one by one. This works but it renders what I need to do more complicated. I’m looking for a strategy for taking a whole string/list and passing it through a process that will give me the tagged values (without the tags) every time I send the whole list through. I’m essentially looking for something like the [route] object that will match a tag and spit out the following value. Again, this is what my list looks like:

tx,183.16806,ty,199.03603,tz,164.23111,ox,0.00000,oy,0.00000,oz,-0.72368

Thanks again :)

#106864
Jun 14, 2007 at 8:29pm

I’ve done a lot of this. Can you give me an idea what you want the output
to be. Do you want to send the numbers to a specific place? Store them in
a coll?

On 6/14/07 3:08 PM, “Daniel Grigsby” wrote:

>
> Clarification…. I’d like to isolate the value that comes after each tag (i.e
> tx, ty etc.). I’ve tried converting the string (or list) into a collection
> using the [Ltocoll] object. Then I used the “nth” message to pull out values
> one by one. This works but it renders what I need to do more complicated. I’m
> looking for a strategy for taking a whole string/list and passing it through a
> process that will give me the tagged values (without the tags) every time I
> send the whole list through. I’m essentially looking for something like the
> [route] object that will match a tag and spit out the following value. Again,
> this is what my list looks like:
>
> tx,183.16806,ty,199.03603,tz,164.23111,ox,0.00000,oy,0.00000,oz,-0.72368
>
> Thanks again :)

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

#106865
Jun 14, 2007 at 8:30pm

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 224 131 72 196617 prepend store;
#N coll ;
#P newobj 224 168 53 196617 coll;
#P message 224 93 384 196617 tx 183.16806 , ty 199.036026 , tz 164.23111
, ox 0. , oy 0. , oz -0.72368;
#P connect 2 0 1 0;
#P connect 0 0 2 0;
#P window clipboard copycount 3;

On 6/14/07 3:08 PM, “Daniel Grigsby” wrote:

>
> Clarification…. I’d like to isolate the value that comes after each tag (i.e
> tx, ty etc.). I’ve tried converting the string (or list) into a collection
> using the [Ltocoll] object. Then I used the “nth” message to pull out values
> one by one. This works but it renders what I need to do more complicated. I’m
> looking for a strategy for taking a whole string/list and passing it through a
> process that will give me the tagged values (without the tags) every time I
> send the whole list through. I’m essentially looking for something like the
> [route] object that will match a tag and spit out the following value. Again,
> this is what my list looks like:
>
> tx,183.16806,ty,199.03603,tz,164.23111,ox,0.00000,oy,0.00000,oz,-0.72368
>
> Thanks again :)

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

#106866
Jun 14, 2007 at 8:43pm

Or perhaps this

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 130 135 69 196617 route symbol;
#P message 20 72 33 196617 dump;
#P newex 130 162 68 196617 prepend send;
#P newex 106 201 47 196617 forward;
#P flonum 527 110 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 466 110 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 405 110 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 344 110 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 283 110 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 222 110 51 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 481 74 26 196617 r oz;
#P newex 429 74 29 196617 r oy;
#P newex 377 74 29 196617 r ox;
#P newex 326 74 25 196617 r tz;
#P newex 282 74 26 196617 r ty;
#P newex 222 74 26 196617 r tx;
#P newex 106 72 72 196617 prepend store;
#N coll ;
#P newobj 106 103 53 196617 coll;
#P message 106 34 384 196617 tx 183.16806 , ty 199.036026 , tz 164.23111
, ox 0. , oy 0. , oz -0.72368;
#P connect 18 0 16 0;
#P connect 1 1 18 0;
#P connect 17 0 1 0;
#P connect 1 0 15 0;
#P connect 16 0 15 0;
#P connect 4 0 10 0;
#P connect 5 0 11 0;
#P connect 6 0 12 0;
#P connect 7 0 13 0;
#P connect 8 0 14 0;
#P connect 3 0 9 0;
#P connect 2 0 1 0;
#P connect 0 0 2 0;
#P window clipboard copycount 19;

Cheers
Gary Lee Nelson
Oberlin College
http://www.timara.oberlin.edu/GaryLeeNelson

#106867
Jun 14, 2007 at 8:46pm

with out a [coll]:

#P window setfont “Sans Serif” 9.;
#P flonum 273 266 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 226 287 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 179 266 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 132 287 69 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 85 266 73 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 38 287 61 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 38 174 50 9109513 zl group 2;
#P newex 38 123 66 9109513 substitute \, n;
#P newex 38 238 294 9109513 route tx ty tz ox oy oz;
#P message 38 96 375 9109513 tx , 183.16806 , ty , 199.036026 , tz , 164.23111 , ox , 0. , oy , 0. , oz , -0.72368;
#P connect 1 5 9 0;
#P connect 1 4 8 0;
#P connect 1 3 7 0;
#P connect 1 2 6 0;
#P connect 1 1 5 0;
#P connect 1 0 4 0;
#P connect 3 0 1 0;
#P connect 2 1 3 0;
#P connect 2 0 3 0;
#P connect 0 0 2 0;
#P window clipboard copycount 10;

can it help you?

#106868
Jun 14, 2007 at 8:49pm

sorry it is the same:

the [substitute] is not needed.

#P window setfont “Sans Serif” 9.;
#P flonum 273 266 59 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 226 287 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 179 266 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 132 287 69 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 85 266 73 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 38 287 61 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P window linecount 1;
#P newex 38 174 50 9109513 zl group 2;
#P newex 38 123 66 9109513 substitute \, n;
#P newex 38 238 294 9109513 route tx ty tz ox oy oz;
#P message 38 96 375 9109513 tx , 183.16806 , ty , 199.036026 , tz , 164.23111 , ox , 0. , oy , 0. , oz , -0.72368;
#P connect 1 5 9 0;
#P connect 1 4 8 0;
#P connect 1 3 7 0;
#P connect 1 2 6 0;
#P connect 1 1 5 0;
#P connect 1 0 4 0;
#P connect 3 0 1 0;
#P connect 2 1 3 0;
#P connect 2 0 3 0;
#P connect 0 0 2 0;
#P window clipboard copycount 10;

#106869
Jun 18, 2007 at 6:20am

Daniel Grigsby schrieb:
>
> Allo! Just looking for some advice on text file parsing. From
> experience, what’s the most efficient way to parse a string like the
> following:
>
> tx,183.16806,ty,199.03603,tz,164.23111,ox,0.00000,oy,0.00000,oz,-0.72368

What you listed above is not a string, its a bunch of seperated
messages, if you put it with the commas into a message box it will spit
out the values one after another.

But if you want to iterate a message like
[tx 183.16806 ty 199.03603 tz 164.23111 ox 0.00000 oy,0.00000 oz -0.72368]

I have an abstraction called siter for it.

The patch below is basically the help file for siter on the left side,
and on the right side an easy way of prepending with a symbol which is
streamed in numbers…

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 422 269 50 196617 print f;
#P newex 500 206 61 196617 prepend set;
#P newex 422 237 50 196617 prepend;
#P newex 422 181 88 196617 route float int;
#P message 422 154 391 196617 tx , 183.16806 , ty , 199.036026 , tz
, 164.23111 , ox , 0. , oy , 0. , oz , -0.72368;
#P newex 189 321 239 196617 route tx ty tz ox oy oz;
#P message 71 178 332 196617 tx 183.16806 ty 199.036026 tz 164.23111 ox
0. oy , 0. oz -0.72368;
#N vpatcher 20 74 620 474;
#P window setfont “Sans Serif” 9.;
#P newex 133 116 29 196617 t s b;
#P newex 50 50 29 196617 t b l;
#P newex 50 143 49 196617 zl group;
#P newex 69 93 74 196617 route int float;
#P newex 69 72 28 196617 iter;
#P inlet 50 30 15 0;
#P outlet 50 165 15 0;
#P connect 1 0 5 0;
#P connect 3 0 4 0;
#P connect 3 1 4 0;
#P connect 6 0 4 0;
#P fasten 6 1 4 0 157 138 55 138;
#P connect 5 0 4 0;
#P connect 4 0 0 0;
#P connect 5 1 2 0;
#P connect 2 0 3 0;
#P connect 3 2 6 0;
#P pop;
#P newobj 57 225 41 196617 p siter;
#P newex 57 260 50 196617 print g;
#P message 57 154 336 196617 2.5 Pitch -100 100 Amp -96 0 Density 3 15
Partials 4 32 Detune 0 50 n;
#P message 26 154 22 196617 fun;
#P comment 104 226 149 196617 iterate at symbols within a list;
#P connect 9 0 6 0;
#P connect 9 0 11 0;
#P connect 8 1 9 0;
#P connect 10 0 9 0;
#P connect 8 2 10 0;
#P connect 4 0 3 0;
#P connect 4 0 6 0;
#P connect 8 0 9 0;
#P connect 7 0 8 0;
#P connect 2 0 4 0;
#P connect 1 0 4 0;
#P connect 5 0 4 0;
#P window clipboard copycount 12;


Stefan Tiedje————x——-
–_____———–|————–
–(_|_ —-|—–|—–()——-
– _|_)—-|—–()————–
———-()——–www.ccmix.com

#106870

You must be logged in to reply to this topic.