txt file to coll

Apr 7, 2008 at 8:49pm

txt file to coll

Hi there,

I’m trying to load a list from a .txt file into coll through the [text] object, my problem is that the list in the text file is a simple list seperated by new lines,

eg

red
blue
green
purple

I can load this into the [text] object but to get it into coll I need to add the appropriate numbers commas and semi colons

eg

1, red;
2, blue;
3, green;
4, purple;

Is there a simple way to do this, I thought of scrolling through the lines with a counter and using pack to add the numbers but i cant add the comma that way.

Any help would be massively appreciated,

Thanks

Jack

#36781
Apr 8, 2008 at 12:52am

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 162 136 36 196617 query;
#P newex 110 257 44 196617 pack i s;
#P newex 110 82 44 196617 t i i;
#P newex 174 199 40 196617 uzi 10;
#N coll ;
#P newobj 110 288 53 196617 coll;
#P newex 144 227 51 196617 route set;
#P message 144 107 41 196617 line $1;
#P newex 144 169 40 196617 text;
#P connect 6 0 3 0;
#P fasten 4 2 5 0 209 224 226 224 226 66 115 66;
#P connect 0 2 4 0;
#P connect 7 0 0 0;
#P connect 2 0 6 1;
#P connect 5 0 6 0;
#P connect 5 1 1 0;
#P connect 0 0 2 0;
#P connect 1 0 0 0;
#P window clipboard copycount 8;

Bang ‘query’.

#126413
Apr 8, 2008 at 3:21am

you could also try this…

put

red
blue
green
purple

in a file called txt.txt and living in max’s searchpath

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P newex 390 64 169 196617 t dump 1;
#P newex 390 123 51 196617 route set;
#P button 390 37 15 0;
#P newex 390 145 116 196617 t b l;
#P newex 390 209 116 196617 zl join;
#N counter;
#X flags 0 0;
#P newobj 390 179 66 196617 counter;
#P newex 390 98 63 196617 text txt.txt;
#N coll ;
#P newobj 390 242 53 196617 coll;
#P connect 5 0 7 0;
#P fasten 7 1 2 2 554 167 423 167;
#P connect 7 0 1 0;
#P connect 6 0 4 0;
#P connect 1 0 6 0;
#P connect 3 0 0 0;
#P connect 4 1 3 1;
#P connect 4 0 2 0;
#P connect 2 0 3 0;
#P window clipboard copycount 8;

#126414
Apr 8, 2008 at 5:53am

jack Keenan schrieb:
> Is there a simple way to do this, I thought of scrolling through the
> lines with a counter and using pack to add the numbers but i cant add
> the comma that way.

but coll will do it for you, if you send coll the packed data it will
store it. Then you can write the coll data to disk or open coll and see
the magic happened…


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

#126415
Apr 8, 2008 at 8:41am

Thanks so much for all your help, I really appreciate you taking the time to help me on this.

I got it working last night, albeit in a rather hacky version which gradually worked through line by line, your solutions are far more efficient and elegant, and should speed up my patch a great deal.

Now I seem stuck with another problem the text object seems to keep breaking on me, i think i may have a patch named [text] somewhere in max’s search patch which keeps loading in instead of the text object, could that be the case? It seems to repair itself if i remove ./patches from the search path and restart.

Thanks again for your advice

Jack

#126416
Apr 8, 2008 at 9:16am

Found the offending patch, all text problems solved!!

#126417

You must be logged in to reply to this topic.