LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array of clusters

I have a text file like this:

[CANDIDATE1]
NAME=Thomas
AGE=25
INTEREST=Swimming
INTEREST=Reading
[CANDIDATE2]
NAME=Peter
AGE=23
INTEREST=Football
[CANDIDATE3]
......and so on...

I want to store each candidate's data into it's own cluster (Name, Age, Interest array) and all clusters from the entire text file result into an array itself (where each element contains a cluster of a candidate). After that, using the array size as limit, pass this array of clusters into a loop whereby each candidate cluster is passed into the loop and processed accordingly.

During the initial text file extraction process, how do i initiate a new cluster creation for each candidate (i would probably have 10 candidates, thus 10 clusters)?
0 Kudos
Message 1 of 9
(3,800 Views)
The attached picture shows you a way to do it.
But there is one problem with the structure of your text file, there are multiple keys "INTEREST" in one section. This won't work with these LV VIs, so you should change it to INTEREST1, INTEREST2 ... and then make an array of strings with it.



greets, Dave

Message Edited by daveTW on 07-20-2007 11:48 AM

Greets, Dave
Message 2 of 9
(3,795 Views)
I agree with Dave that the config file VIs will work for you. The arrays start with element number 0 as all LV arrays, so you would have INTEREST0, INTEREST1, INTEREST2 ...

Lynn
0 Kudos
Message 3 of 9
(3,774 Views)
Hi,

I see one problem, your first candidate had several interests. You have to make sure every key name is unique. So better use the OpenG configuration tools they have all this covered (I think)

Ton

Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 9
(3,771 Views)

Nice example Dave!

I have one "hair-splitting" comment.

The File ref and error clusters should be wired to SR's to handle errors, and the posibility that the array of section names is empty.

Done splitting-hairs.

Again, nice example!

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 5 of 9
(3,764 Views)
Hey Ben,
I think this hair is as thick as a rope, of course, if the text file is empty or of wrong format, this is the case where the for loop is never entered. Thanks for the hint. Smiley Happy
@ vcteo: did you succeed?

greets, Dave

Greets, Dave
Message 6 of 9
(3,742 Views)
Hi guys, thanks for your support. I just got in today, so i'll start working on it and see how it goes.

DaveTW, thanks for your input. I understand that Labview has these config VIs but the reason i'm not using them is because i have CANDIDATES with different number of interests, some may have 2 others 3. In other words, i wouldn't know in the beginning how many dedicated INTEREST variables i would need. That's why i chose to have INTEREST as an array.

I'll try out both methods and see how it goes.
0 Kudos
Message 7 of 9
(3,715 Views)
What about:

INTERESTS = Swimming, Reading, LabVIEW programming, etc.

Leave as a string or split at the commas.
0 Kudos
Message 8 of 9
(3,710 Views)
Hi guys, i succeeded Smiley Very Happy

I used Dave's method of config VIs and Bill's idea of using commas to place all interests unde 1 INTEREST key. Saved me alot of time playing around with match patterns VI etc.

Thanks guys!
0 Kudos
Message 9 of 9
(3,704 Views)