Is there a way to get [qlist] to import information off a text file as a list of symbols and floating points? The only way given in any of the examples has been using the print object (which displays the information, but won't let me compute with it?) or using the receive object [r] and I can't use that in this instance.
Any help would be greatly appreciated!
-
Reading in a list of symbols with qlist
-
A quick reply about [iem_pbank_csv $1 $2........ ]
The file that you are looking for needs to be made.. it will be your text file that stores the data.
It should be in your working folder with a name like mytextfile.txt. Then you would use..[read mytextfile.txt brw] ........(brw works better for some reason, which I cannot remember straight away.
so open a new text file.. with that name
and type into it (for example)
the (enter for every line)
fat
cat
sat
on
the
mat
0
0
0you have 10 pieces of data
now put an object in your patch [iem_pbank_csv 1 10] ....one column ten rows
All can be changed of course!Here is an example with any luck...........iem_p.pd
David. -
@whale-av wow! thanks for the effort! Is there anyway to do this without slist, though?
sorry for being suck a picky pain in the ass... I just can't use slist in this scenario
-
I didn't want to have to explain the full extent of my problem for fear of confusion, but here goes: basically I'm writing a text file with a name and data that is procedurally generated by symbols and floats. This way I can create duplicate files to read multiple pieces of information into multiple copies of the same abstraction without having to manually rewrite the name for each one ("piece of data 1" piece of data 2" etc)
Now to read that data back, I need to use a read function that will use the same names procedurally generated as the data input readouts, but, using [qlist] (as well as [slist]) requires a s "name" and r "name".
You can't generate send and receive names from a symbol.
Or can you?i hope that made any sense, thanks for sticking with me!
-
Sorry, there were errors in the last patch...
Here is a new one where slist works as expected.
iem_p_example.pdThe output when you bang the bang at the top does not have to have the add, or the comma, ......... you can manipulate the list as it exits from [r datalist] into the format that you want. (remove [pp add] etc.).
David. -
cool, it's pulling in most of the data but for some reason the ends of the lines are getting cut off. For example "pieceofdata 1;" loses the "1" and the ";" any idea as to why that might be?
-
Yes, you can generate send and receive names and pretty much anything from a symbol.
If you have a list of symbols you can pump them, one at a time, into the name of your abstractions, and use them as you wish. An example might be forthcoming,............ duh ........... here it is... its a mess and you will have to make what you can and then do some research...iem_p_example2.pd
and you need these two in the folder as well:
example2.pd
example_abstr.pd
and here is an example text file for that folder, in case anybody else is interested:
mytextfile.txtSo:
open it [iem_p_example2]
click the bang at the top as before
click the bang on the left to send it all to slist
(replace these bangs with delayed loadbangs once your work is complete)now open [example2] ...... at the bottom in the middle...
and inside [example2] .....
open [pd example_abstr] .... at the bottom againand you will see a number of patches have been created
They have been given numbers, and names........ your names from your list
And inside each one, where $1, and $2 are used (NOT! in a message box.. that is another matter)
the $1 and $2 will have been replaced by the number and the name that you see in the title of each little patch (abstraction)
Notice that they were in fact created by $2 and $3 in the message (in example2.pd) that created all of these abstractions. $1 in that message gave the position of each abstraction on the canvas, so that they were not on top of each other.
IF YOU SAVE THIS PATCH WITH YOUR CHANGES......... delete all of the abstractions and the contents of the slist window in [iem_p_example] before saving..... or you will end up with multiple copies of the abstractions on top of each other every time you save!!!!!
Best.. going to bed... sorry.... hope that makes sense...
David.UPDATED 28.02.2015 11h02 central European time
-
i'll check it out. Thank you!
-
When I got up this morning........ please note that I could not resist improving the example... a bit.
It now shows your data inside the abstractions, and each has a receive object with your data as part of the name so that you can test using [send].I have just seen your post about your data being truncated. Could you post your text file so that we can see the data you are trying to work with, and a little note about how you want to use it?
It is probable that the space in your data is seen as a (list) separator (a bit like these forum pages). If you can eliminate the spaces, or replace them with _ then that might solve your problem. But it would of course be better to look for a genuine universal solution.
I am working in a similar vein maybe, trying to build patches from data on a blank canvas.... i.e pure abstractions... patches that only exist temporarily and are constructed entirely dependant upon external data...
So I will look at your problems as they will someday also be mine.@gsagostinho .... Yes, [msgfile] looks interesting...
David. -
nice! i thought about that idea too for a bit, the concept of pure data metaprogramming. i believe you could also do such a thing by creating the .pd file with c++ possibly? or perl? possibly? from there, the .pd file created could communicate back to the creating perl or c++ file with a .txt file of data... an idea i had, feel free to explore it OBV........ though this has probably been done before?
-
sorry but i'm still not clear as to how you could use a symbol as the name of a send and receive line. how can you create an object like [s NAME] where NAME is a symbol you generate on the fly?
-
perhaps this will show you EXACTLY what i would like to do? could you possibly edit this patch so it works?
-
@AWilliams Maybe something like this?
-
Or a fancy gui version if you prefer:
Here's the .zip: dynamic-snd-rcv.zip
Basically [s$] works by packing a float and a symbol into a list, such that any random float has a unique, user-definable identifier to go with it. [r$] initially listens to all data coming via the [s a-list]/[r a-list] pair (which are inside the abstractions), but then filters out based on what symbol you tell it to look for. You can define [r$] by clicking the L and then sending whatever data you want through a [s$] , or just typing it in manually. Long story short you can now dynamically define a [receive]Because this is just proof on concept, and because I really should be starting on my university homework, I limited the amounts of data you can send through (which is 1 float). If you wanted to send more data through, you'll need to find a way to send a separate list of floats/symbols/whatever that you would pack BEFORE giving it to [s$] to pack with your "symbol argument".
Btw, the name "a-list" is completely arbitrary. It just can't be "$0-list" because the abstractions will have different $0 values and won't talk to each other.
-
Yes... homework before homeplay!
Try this.. it half does what you want.. it's a start as they say. It will build a filing cabinet. Not a list as such. A list could be built afterwards from the filing cabinet, then the items in the list could be found using [slist], but sorting the list afterwards? More work.
new try.zip
I will try to build in a way to update the contents of each drawer when I get the time. That should be easy, as I have mentioned in the patch comment.
The drawers in the cabinet could be made to send their contents to different places when they are called (by [r index$1]), by using [s $1-list], instead of [s a-list]. The fifth drawer (drawer (5 symbol)) would send "5 symbol" to [s 5-list]...... if you wish. -
@whale-av said:
The drawers in the cabinet could be made to send their contents to different places when they are called (by [r index$1]), by using [s $1-list], instead of [s a-list]. The fifth drawer (drawer (5 symbol)) would send "5 symbol" to [s 5-list]...... if you wish.
I guess I'm confused as to what you are trying to do. I looked at your example but I couldn't understand why you need a dynamically changing receive. After I entered a float and symbol pair into the send, it entered the same symbol in the receive but it did not output any index info, and it wouldn't link up the the [s$] with the same name. Could you be more specific with your end goal?
-
I have bypassed some of your work, but left it in place in case you need it... that makes a mess I know.
Here is a completely working (in windows...hopefully in OSX) cabinet. I will try to tidy it, or you can if it works for you.
Any symbol sent will be saved in a drawer. Drawers are only created when a symbol is saved, and they are created with the number (from the slider).
When you select the same number they can be re-written, ... updated, written over.
The "receive" fader reads the contents of the drawers.It is not a list that is "searched", but abstractions that are searched (by index at the moment), and could contain more than one symbol if desired.
The control "s$-help_new" is your main patch as before.
To see the contents of the drawers open [s$_new] from within the patch and click [pd cabinet] at the bottom.
better.zipI will reread your posts to try to understand whether I am helping you or not.
-
@rjpg i've been trying to use qlist to read in floating points from a .txt file. The txt file looks like this:
variablename1 4.0;
variablename2 3.2;
variablename3 659.0;
etc.....in order to read in any of these values, qlist requires me to make an object like [r variablename1] and output the value 4.0 from there
which works, for this one abstraction, but if i wish to use multiples of the same abstraction in the same patch, the [r variablename1] objects need to be localized.
My initial thought was, write "$0-variablename1 4.0;" to the .txt file instead of "variablename1 4.0;" however, a [r $0-variablename1] object just flat out don't work.So my other thoughts were
- is there a way to just load in as a symbol "variablename1"?
which appears to require slist and iem_pb but seems unnecessarily complicated
or - can i create an [r symbol] like instance that will allow me to import from qlist the number 4.0 if i pass it the symbol "variablename1"?
- is there a way to just load in as a symbol "variablename1"?
-
@whale-av all of your examples with iem_pbank_scv will load in the first half of the symbol "variablename1" but when it gets to the space it cuts off the floating point i need, "4.0"
-
Got there!
"sr" was the required message for open panel.............Working even better.zip working patch to import your text file.