03-03-2016 03:40 PM
Ok, so I'm a very new person to Labview but understand the layout/coding if it is explained properly. I'm having a problem understand what I need to do next in my small program.
What I am doing is reading 2 files. 1 file shows Model names of computers, and I have that into a 1D array. The second file is a compiliation of Received computers in a day (Incoming Shipments). So far with the second file, I have that into a Spreadsheet string to array with "%s" Format string, "-" Delimiter and 2D Dbl array type. Output of Spreadsheet string to array goes into an Index Array with an Index colum of "1". Everything is pulling the information that I need/want.
What I want to do is compare the set Model Names from the 1st file and count how many of each model arrived through the second file.
EX
Total Received: 106
X Model: 40
D Model: 35
C Model: 31
I'm stuck on how to do the next step. I've tried searching for examples, but none are helping enough to jog my brain. Any help would be appreciated.
Solved! Go to Solution.
03-03-2016 03:54 PM
You are missing the sub-vi you call in "Project 1.vi". Also, we can help you better if you give us sample .txt files you are reading in (or just copy/paste some of the lines) so we have an idea of what you are trying to do.
That having been said, I'd look in to storing your data in an array of clusters. Each cluster has a string for the model and a numeric for the quantity. For every computer in your second file just search the array for the correct model and increment the quantity accordingly.
03-03-2016 04:16 PM
I had to make some assumptions about your data, but this should work.
03-03-2016 07:21 PM - edited 03-03-2016 07:21 PM
As far as couting the different models, Variant Attributes work extremely well.
03-04-2016 07:28 AM
Sorry, didn't realize I was using a Subvi, I changed it to not have the Subvi and used the original code. Re-uploaded VI.
As far as the data, here is what I have:
Models.txt has 15 Models total:
Model A
Model B
Model C
....
Model N
Model O
Receiving.txt has anywhere from 800-1500 lines depending on the day.
"Serial number of unit" APP-Model-A 13.3/2.5/2X2GB/500-5400/SD 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:00:56 AM
"Serial number of unit" APP-Model-A 13.3/2.5/2X2GB/500-5400/SD 04FUNCTREC99 Completed Config-Manager, Default 3/3/2016 7:01:37 AM
"Serial number of unit" APP-Model-A 13.3/2.5/CTO 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:02:18 AM
"Serial number of unit" APP-Model-A 13.3/2.5/2X2GB/500-5400/SD 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:06:25 AM
"Serial number of unit" APP-Model B 11.6/1.6/4/128FLASH 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:08:29 AM
"Serial number of unit" APP-Model F 11.6 CTO 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:08:29 AM
"Serial number of unit" APP-Model G 13.3/2.9/2X4GB/750-5400/SD 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:09:10 AM
"Serial number of unit" APP-Model C 13.3/2.5/2X2GB/500-5400/SD 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:09:51 AM
"Serial number of unit" APP-Model M 13.3/1.6/4/128FLASH 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:09:51 AM
"Serial number of unit" APP-Model K 13.3/1.6/4/128FLASH 04FUNCTREC99 Processing Config-Manager, Default 3/3/2016 7:10:32 AM
I've already got it to where it is taking the second column and separating the "APP-Model-A" to just have strictly the models in an array.
Hope this is enough.
03-04-2016 07:34 AM
Here is a secret with the Read Text File that will make your life a little easier. Right-click on the node and you will see an option to "Read Lines". Set the count to read to -1 and you will have an array of strings, each element being a line from the file.
03-04-2016 08:12 AM
Thank you Knights of Ni. What you provided is working for now but numbers are incorrect according to me adding the receiving up manually in Excel. But I should be able to decipher from here and move on.
But FYI: I put a probe after set variant, coming up with wrong amounts. So maybe my data retrieval is wrong?
'Model-A' ->10 but it should be 24 according to excel.
03-04-2016 08:15 AM
From the text file you posted above, you have the dash in Model-A but no dash in Model B. Could you have both "Model-A" and Model A"?
03-04-2016 09:55 AM
@crossrulz wrote:As far as couting the different models, Variant Attributes work extremely well.
In my experience, variants are overkill. A simple sum of an array of 0s and 1s does the trick much faster.
Cheers
--------, Unofficial Forum Rules and Guidelines ,--------
'--- >The shortest distance between two nodes is a straight wire> ---'
03-04-2016 10:19 AM
There should be dashes. Which is why I mentioned my data retrieval was wrong in one of the replies. It actually was wrong since I noticed the numbers were not adding up. I fixed the problem and now everything works.
Thanks Knights of Ni for the example and KLutz for helping me realize that there was a problem with the data. I didn't noticed it until you mentioned it.