LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

cellecting and saving data into excel or CSV file spreadsheet

Solved!
Go to solution

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

0 Kudos
Message 1 of 20
(8,021 Views)

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.

Message Edited by Ravens Fan on 07-22-2009 10:56 PM
Message 2 of 20
(8,001 Views)

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 

 

0 Kudos
Message 3 of 20
(7,981 Views)

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

 

Message Edited by Norbert B on 07-23-2009 08:59 AM
Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 4 of 20
(7,976 Views)

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?

Message 5 of 20
(7,973 Views)

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.

0 Kudos
Message 6 of 20
(7,958 Views)

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.

Message 7 of 20
(7,949 Views)

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 

Norbert
----------------------------------------------------------------------------------------------------
CEO: What exactly is stopping us from doing this?
Expert: Geometry
Marketing Manager: Just ignore it.
Message 8 of 20
(7,932 Views)

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.

0 Kudos
Message 9 of 20
(7,911 Views)
That shift register serves no purpose.
0 Kudos
Message 10 of 20
(7,907 Views)