09-02-2016 10:09 AM
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.
Solved! Go to Solution.
09-02-2016 10:24 AM
@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
09-02-2016 10:27 AM
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.
09-02-2016 10:28 AM
Ben's sounds faster 🙂
09-02-2016 10:31 AM - edited 09-02-2016 10:31 AM
I would just use Variant Attributes...
09-02-2016 10:36 AM
@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
09-02-2016 10:37 AM
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
09-02-2016 11:47 AM
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.
09-02-2016 03:29 PM
09-05-2016 06:02 AM
@AnkitRamani wrote:And Matt,
Is it possible for you to upload vi in 2012 version.
Here is his VI saved in 2012.