LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to sort out the rows from the the table which belongs to the same name and save to the .txt file ??

Solved!
Go to solution

Hello, 

 

I am facing one problem, that I am reading the .txt file which has several rows and columns.

Third column represent the group name, like group 1, group2 and group 3. .txt file attached in the attachment.

I wanted to generate the group wise .txt file, like all raws which has 3rd element name group 1 should be in one .txt file and all the rows which has 3rd element name group 2 should be in one .txt file.

I hope I have explained my problem well.

 

pelase guide me how can I have solution for this problem.

Thank you very much in advance.

 

Regards, 

Ankit.

Download All
0 Kudos
Message 1 of 10
(4,242 Views)

@AnkitRamani wrote:

Hello, 

 

I am facing one problem, that I am reading the .txt file which has several rows and columns.

Third column represent the group name, like group 1, group2 and group 3. .txt file attached in the attachment.

I wanted to generate the group wise .txt file, like all raws which has 3rd element name group 1 should be in one .txt file and all the rows which has 3rd element name group 2 should be in one .txt file.

I hope I have explained my problem well.

 

pelase guide me how can I have solution for this problem.

Thank you very much in advance.

 

Regards, 

Ankit.


I will outline the task but you will have to code it up.

 

Pass the array to a For loop and let it index off the incoming tunnel.

Isnide the For loop use an index array to pull each collum and bundle those into acluster where teh group is the first element in the cluster.

Pas the clusters out and let the For loop index them into an array.

Pass teh array of cluster to  a "sort 1d array".

Pass the sorted array to another For loop and again let it index.

Write the values from the cluster to a file as long as the group name has not changed.

When you encounter a new group name close the previous file, open another...

 

I will let you work out the logic to decide if the group name changed.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 10
(4,220 Views)

You can try this:

1. Get the 2D array of strings (main array) before the while loop, initialize a shift register with it

2. Delete the first row from the array (find its "group" element) and put it into a separate array (group array)

3. Keep searching the main array for the group name, every time you find a match delete from main array and add to group array. (may require an inner while loop)

4. When you stop finding matches, write the group array to a file

5. Start again with the new first element of main array and repeat steps 2-5, unless main array is empty and you can stop.

Message 3 of 10
(4,215 Views)

I would just use Variant Attributes...


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 5 of 10
(4,209 Views)

@Gregory wrote:

Ben's sounds faster 🙂


Mine may be faster to write but for large files yours will be afster becuase it can work "in-place". My approach will required additional arrays so with large files it may run slower.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 6 of 10
(4,200 Views)
Solution
Accepted by topic author AnkitRamani

I provided a simple example that will work.  Feel free to use whatever method best suits your needs because there are several good ideas on this thread already Smiley Very Happy

 



-Matt
Message 7 of 10
(4,199 Views)

Thank you very much all for suggestions.

I will have a look on given suggestions and let here know.

 

And Matt,

Is it possible for you to upload vi in 2012 version.

 

Thank you very much once again.

0 Kudos
Message 8 of 10
(4,162 Views)
Solution
Accepted by topic author AnkitRamani

I would do something like this provided you know from the start the number of existing groups (it would even be simpler with conditional terminal, starting LV2014 I think).

 

Ben64

Message 9 of 10
(4,128 Views)

@AnkitRamani wrote:

And Matt,

Is it possible for you to upload vi in 2012 version.


Here is his VI saved in 2012.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 10 of 10
(4,080 Views)