03-03-2017 12:41 PM
Hello,
i need to read a table in a spreadsheet with boolean and then accordingly to the value of the table, do some actions (if 1) or don't do any action (if 0). So i guess i need to send the spreadsheet into an array and then loop into the array elements, read them, and use the result as case input in a case structure.
I am not a LabView expert though, so i don't know how to do it. Someone can help me?
Thanks a lot
stefania
Solved! Go to Solution.
03-03-2017 01:41 PM
What do you mean when you say spreadsheet? Do you refer to an Excel file (.xls or .xlsx) or do you have your data stored in a CSV or text file (comma or tab delimited) that can be read into most spreadsheet programs?
If you are working with Excel files, you'll want to use the Report Generation Toolkit, which is a toolkit offered by NI that, in the past was sold separately but I believe is now included as part of a professional license.
If working with CSV, there is a VI on the File I/O palette called Read from Spreadsheet File that will read the file into an array, using the character that you specify as the delimiter (most often a comma).
03-03-2017 01:50 PM
Hi, thanks aputman,
CSV is good for me. The problem is once i read the file into an array, how i can loop through it and use each element as a case input for a case structure. I am not sure if I was clear enough. I guess it must be pretty simple, but i am new to labview and i am struggling with it!
Thanks again for your time
03-03-2017 02:01 PM
Share with us what you have tried. There are many ways to interpret what you have said. If you can show us an example input file, and what you want to do with it, I'm sure you'll get a response.
You'll most likely need a For Loop or While loop with auto-indexing turned on. If your data is a 2 dimensional array, you may need nested For loops. Again, your request is too vague to be any more specific.
03-04-2017 12:06 PM - edited 03-04-2017 12:07 PM
On the first page of the Forum, there are links to LabVIEW Tutorials. One of the earlier items covered is Arrays and how they interact with For Loops. Spend some time (a few hours) with the Tutorials, try the things they tell you, reproduce the examples, do the exercises, and you will learn the elementary LabVIEW stuff you need to solve your own problem.
Bob Schor
03-06-2017 01:05 PM
Hi, thanks a lot for the answers!
I wasn't clear (at all) in the first message, so maybe the best thing is to show you what I have done. Sorry for that.
I need to implement a program which interacts with arduino in order to use a glue dispenser. So in the program in attachment, i am looping over a boolean array and, according to the elements value, i pass to arduino different commands (this is what i was trying to say in the first message).
My next step is to read from a csv spreadsheet and pass it to the array.
So in the spreadsheet i will have something like this for example:
000011111000000011111100000
1111100001111111100000111111
000011111000000011111100000
and then i need convert this to the array in the program.
I've read the tutorial but i didn't know if my idea of proceeding was correct (i still don't know actually if there is a way to optimize it since it is my first program 🙂 ).
Another think i need to do is as i loop over the vector, i change the color of the round led marking in this way that i have processed the element. This i have no idea on how to do (and if it is possible).
Thanks for your time anyway. I really appreciate it.
03-06-2017 01:59 PM - edited 03-06-2017 02:00 PM
@Stefis84 wrote:
My next step is to read from a csv spreadsheet and pass it to the array.
So in the spreadsheet i will have something like this for example:
000011111000000011111100000
1111100001111111100000111111
000011111000000011111100000
and then i need convert this to the array in the program.
So no commas in a Comma Separated Values file? Does not really matter.
Based on what you showed here, I would use the Read From Text File. Right-click on it and you will see an option to "Read Lines" or something like that. Enable that and set the number to read to -1, which will read all of the lines. The output is now an array of strings. Now you can just autoindex on the line, parse it, and send it along.
03-06-2017 05:09 PM
Hi,
thanks again for helping me.
I have tried this solution, although for example if i have a file as the one in attachment, it gives me the wrong pattern (also in attachment).
Thanks
stefania
03-06-2017 07:57 PM
I see. It takes the coma also. I need to manipulate a bit the string.
Thanks again for the help 🙂
03-07-2017 12:57 AM