07-22-2009 05:44 PM
I want to record and save my data collected through an experiment into an excel or CSV file. i want my data on a spreadsheet, distributaed iin a column or row. However, I am unable to do this using LabVIEW 8.6.
I have attached the programming that I have created using LabVIEW.
Please give me some suggestions on how I can resolve this problem.
Thank you.
Samia
Solved! Go to Solution.
07-22-2009 09:54 PM - edited 07-22-2009 09:56 PM
How are you unable to do this with LabVIEW? What problem are you having? Are you getting an error message? Please be more descriptive in what is going wrong.
I do see one problem in your code. It is a race condition caused by your use of local variables. The local variable of Path will likely get read as soon as the program starts and will be passed on to the Write Spreadsheet File. But it looks like you don't want the path to be defined until the user has pressed OK button to get out of the while loop. You should be using a wire for the path rather than a local variable to get the value to the Write Spreadsheet File VI.
07-23-2009 08:36 AM
Hi Ravens Fan,
when I run the program and collect the data into a file, the file does not actually show me all the results. for example, i acquire five numbers from running the program, but when i open the file in which the data is collected, the file shows me only two or three numbers, saying some error has occured.
Another problem is: the data is not being placed in an excel or CSV spreadsheet. i acquire the data as <48.00, 75.00, some error has occured, 65.00> (this is an example). I want to collect the data in a column in excel or CSV file. if you see my program, you will see i connected a string constant saying exl. in order to save my file in an exl file. however, it's not working.
My write to file VI is not working since i don't see any data being collected in that file. Do I even need to use the write to file VI here?
Please let me know if you need to know anything else.
Thank you.
Samia
07-23-2009 08:58 AM - edited 07-23-2009 08:59 AM
Samia,
looking into your code reveals that you lack of any architecture valuable to the task. Furthermore, your code is full of race conditions and too many "static decisions".
First of all:
A CSV-file is no XLS-file. So please do not create a filename *.xls if you are writing csv. Excel has its own format for files (xls) and you must use Excel to create such a file (or use dedicated converters).
So here a short list of improvements:
1. Switch to a "real architecture". I recommend you either to User Interface Event Handler or Standard State Machine.
2. Do not use variables and sequence structures. Sequence structures are obsolete anyways if you switch to a proper architecture.
3. Do not write two files except if you really need it. Configuring a static path in the "Write to Measurement File" is not a good idea....
hope this helps,
Norbert
07-23-2009 09:01 AM
It has says the words "some error has occurred" in the file? That is very strange.
I didn't notice last night, but see today that you have two file functions going on. A write to spreadsheet file and an Express VI. The express VI is writing to test.lvm. The spreadsheet file is writing to whatever file path you have in the program before you hit the start button (unless you have since cleaned up the local variable problem.) Which file is giving you the error? Is there a reason you are using both? If you are trying to write to the same file with both, then you could be getting some sort of error with one having the file open while the other is trying to access it.
Which file is giving you the error message?
07-23-2009 03:43 PM
I have made some changes to my program. I don't understand why i need event interface handler. I have not used it in my program.
still cannot collect the data in an excl sheet (not CSV) in a colum.
07-23-2009 04:16 PM
Your VI works just fine for me. It creates a text file with 5 values separated by commas.
If you want to have each value saved in a different row, wire a True constant to the Transpose Array input of the Write to Spreadsheet file.
07-24-2009 02:11 AM
alams wrote:[...]still cannot collect the data in an excl sheet (not CSV) in a colum.
I repeat what i already wrote: In order to create xls files, you must use Excel. You cannot create xls simply using LV or any other programming language (except you know the internal layout of an xls file which is, as far as i know, not open source).
One thing you can do is to create a text file which can be directly imported in Excel. CSV and "spreadsheet" files are such files. The other thing is to use ActiveX or .NET in order to "remote control" Excel and pass the data to it in order to write them to file.
hope this helps,
Norbert
07-24-2009 12:50 PM
oh ok, I finally understood that I can NOT simply use LV to create exl. through all of your helps, I have been able to get my data in an exl spreadsheet in a column.
i don't think i will neet to create any text file or active X or NET. I have tried using Write to text file and read from text file, but it does not seem to make my program efficient in any way. i have attached py final work.
Thank you very much everyone. I really appriciate all of your help.
07-24-2009 01:09 PM