Parsing CSV (character separated values) Help!
-
In order to get Isadora and an EEG device to play nice with each other, I need to be able to parse incoming CSV data from an Arduino to separate serial watcher outputs. The incoming packets (lines) from the Arduino come in about once per second and look like this:
0,77,63,7145,15348,6599,6547,13130,14972,13325,21103
0,67,69,169763,25887,6613,2915,3655,6518,1890,2511
0,69,66,140433,15179,5507,15399,17747,17367,16312,10916
etc. etc.
For example: each of the 11 values from the first line would be simultaneously transmitted to a separate "msg rcv" output, then a second later line 2 would be transmitted the same way, and so on.
Is this possible? Also, please understand that I did not know what CSV or even serial data parsing was until about an hour ago, so I'm looking for a noob explanation.
Thanks in advance to anyone that can help!
-
If you double click on the serial watcher actor a text box pops up
paste this in:a:int=5 digits ',' b:int=5 digits ',' c:int=5 digits ',' d:int=5 digits ',' e:int=5 digits ',' f:int=5 digits ',' g:int=5 digits ',' h:int=5 digits ',' i:int=5 digits ',' j:int=5 digits ',' k:int=5 digitsAnd you should get the data coming out of each output. If the numbers are ever longer than 5 digits then amend the length number - it is the maximum, so will accomodate smaller numbers as well.Havent tested it with actual setup, so might need a bit of tweakingHTHNick -
That did it! Thanks Nick! The strength of this community is pretty astounding.
-
That code above works beautifully (and I've since noticed that it's also in the manual... d'oh). The only thing is that the actor slows down to a crawl while parsing all that data. Is there a way to exclude particular values? I've tried a few things but the only thing i can seem to do is exclude values off the end. I'd like to be able to make an actor that only reads the value in the fourth place, for instance.
-
you could alter the arduino code to only send that value - I would be surprised if that is whats causing it slow down, its not much data, and your original post mentioned it only being sent once a second - is that still the case?
-
yes, still only sending data once/second. thanks for sticking with this btw :)
i attached the user actor i'm working on. i have a serial watcher (binary) in there as well just to monitor the connection. when a-c (signal strength, attention, and meditation) are running, the text watcher keeps up with the binary watcher just fine. when i add delta wave, it starts to struggle, and with anything beyond that it starts to drop packets. removing the binary actor doesn't seem to make a difference in regard to the speed.
ideally, i'd like to be able to create a few specialized user actors for specific brainwaves, i.e. one for attention/mediation, one for theta, one for delta, etc. i have a feeling that things would run smoother if i could set things up like that. it would also be simpler to discard unwanted data at will. that means i'd need to keep the arduino code as-is. i don't think that's the problem anyway -- it runs like clockwork in arduno serial monitor. also, for the sake of experimentation, it would be nice to have all the data at my fingertips.
the trick would be to get a piece of code like: ',' d:int=5 digits ',' that would only read the fourth integer. unfortunately, "d" in this case only seems to be a label. you could enter: q:int=5 digits ',' dogs:int=5 digits ',' a:int=5 digits ',' and the actor would still output the first three integers of the data in order.
is there another solution within isadora?
8642ba-mindflex.iua -
I've just noticed some of the numbers in your original post are more than 5 digits long (they are 6 digits) - this would cause the entire message to not be recognised - increase the value for the digits looked for in the stream - do you know what the biggest number you will get for any of the readings is ?
If not set it to a high number to be safer -a:int=7 digits ',' b:int=7 digits ',' c:int=7 digits ',' etc..... -
if you want to ignore some of the values then do not assign them -
5 digits ',' 5 digits ',' 5 digits ',' a:int=5 digits ',' 5 digits ',' 5 digits ',' 5 digits ',' 5 digits ',' 5 digits ',' 5 digits ',' 5 digitsshould produce a single output and assign the 4th value in the stream to it (but may fail for the same reason as above - looking for enough digits some times)Personally I would use a single actor that gets all the values in a message, and then distribute them to where they are needed, rather than multiple parsing, but that may be a question of style rather than correctness if multiple serial in watchers will process a single message. -
Why do you think you are missing values - is the message being sent regularly every 1 sec - do you see values update once a second ?
Binary serial watcher might be misleading you as it displays different info - it will trigger after every 4 bytes - any 4 data bytes that come down the serial port - each digit is a byte, and so are the commas, carriage return etc... so you will get multiple triggers firing on the binary actor for each single trigger firing on the character watcher that reads 11 values - when you are only sending a couple of values they will both trigger around the same rate - but as the message gets longer the binary actor will trigger more times for each received message