02-14-2014 06:17 PM
Hello er_10_1999
What your code currently does causes "race conditions". Essentially there is no way to say which of your write loops will execute first. In addition, you will encounter an error if you try to open a file that is already open. You don't need to open and close the file twice, you just need to open it once and append each column one at a time.
02-16-2014 05:49 PM
Hello Jonathan,
Thank you for the information. However, I can't seems to find a way to open it once and append each column one at a time, would you have any suggestion about how I proceed about it. My code from the February 9th post(see below), has a "Excel Get Last Row.VI" and "Append Table to Report.VI" which allows insertion and appending of data in the 1st column only, but the issue here is that it doesn't allow any additional setting to allow insertion and appending of other set of data in a separate column of the same excel worksheet.
I understand you strategy of "open it once and append each column one at a time"; however which VI would allow this stragety to work.
Would you have any recommandation of we could proceed about it.
Thanks
Eric
02-17-2014 09:03 AM
Hi Eric,
Typically when dealing with repeatedly writing to a file, you will have a loop and write repeatedly in the loop, and outside of the loop you can open and close the file. This example shows one way of doing this, however since you're not using a text file, you should instead just use the report generation VIs.
http://digital.ni.com/public.nsf/allkb/F55FD21DFEF0C3C1862571F500023123
Another way to do it would be to store the file reference in a functional global varaible (http://labviewwiki.org/Functional_global_variable) and have functions for open/write/close and call them when necessary. This option cleans up the block diagram a bit more, as there doesn't have to be a file reference running across the entire code, but it is a little bit more difficult to implement.
Hope this helps.
-N
02-17-2014 07:22 PM
Hi Jonathan,
Thank you for the information. I was thinking about another way to possibly address the situation, I don't know if it is implementable. In this other version of my block diagram code(see attach picture) I have a loop for the all code and at each iteration, Y-axis and X-axis data are saved and appended into two seprate text file.
Do you think they could be a way of let says once all my loop program has finished executing, with all Y-axis and X-axis data saved and appended into the two seprate text file, to have a function or an additional block diagram code that would extract the Y-axis data from the 1st text file and import it into the 1st column of an excell worksheet, and then have the X-axis data from the 2nd text file imported into the 2nd column of the same excell worksheet. If that is feasible that would probably avoid to deal with iterating and saving on an excel file each time.
What do you think, would you have any suggestion ?
Eric
02-18-2014 08:29 AM
Hi Eric,
Better yet, you could just form it into a single large array and write it all to the same text file. If you wire something to the edge of a for loop, it will auto-index and automatically build an array of the values. You may have to change the auto-indexing mode for the 2-D array, you can do this by right-clicking on it and selecting the auto-indexing option.
After the loop iterates, you can use the build array or Insert into Array functions to combine the x and y columns and then write them all to a text file.
02-19-2014 01:06 PM
02-19-2014 07:45 PM
Hi Nathanael,
Just to be more precise on some of the issues I'm facing, I've attached one of the code that I implemented to give you an idea of the problem with insertion in different columns.
In that code I'm saving the same data in 2 separate excel files, just to test if I can perform insertion in 2 files but in different columns, unfortunatelyt it doesn't work, because if I set the MS office parameter in "Append to table VI" to a specific value(say column to 5), my other "Append to table VI" will also be set to the same value, regardless to the fact that I'm using separate "Append to table VI". In my understanding if I'm using two different "Append to table VI" I should be able to set the MS office parameter of one to says (row=0,column=0), and the other one (row=0, column=2), and when I run the program I should have my data in one file save in the 1st column, and in the other file saved in the 2nd column, but it looks like, you can't configure that settings.
As usual waiting for you insight regarding insertion and appending in separate columns
Eric
02-20-2014 10:02 AM
Hi Eric,
You need to fill out the 'MS Office Parameters' input of the Append Table to Report.vi. Please see the detailed help for more information. http://zone.ni.com/reference/en-XX/help/371361J-01/lvreport/append_table_to_report/
-Nathanael
02-20-2014 12:42 PM
Hi Nathanael,
Thank you for the answer, that exactly what I'm doing, and for strange reason, whenever you fill out the 'MS Office Parameters' input of one of the Append Table to Report.vi, that automatically set the other 'MS Office Parameters' input of the other Append Table to Report.vi to the same input parameters, which cause a problem because it doesn't alllow different settings of 'MS Office Parameters' for different Append Table to Report.vi in the same block diagram.
Besides using Append to table report VI, would have any idea of another way I could proceed in order to insert and append data in an existing "excel file" with the data inserted in separate columns.
Thank you
Eric
02-20-2014 12:47 PM