LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to spreadsheet while loop problem

Solved!
Go to solution

Hello dear Labviewers. I have a "write to spreadsheet" with a 2D DBL array connected to it, but the problem occurs inside the while loop. I want exactly those six time values in my excel document, but it restarts after every "two seconds" and i can't get rid of that problem. I want exacly the same numbers in the Excel document as it is in the array.

 

I have tried to move both "write to spreadsheet" boxes outside the while loop, but the Excel document doesn't show a single value from the array, when i do that. It only shows the two Headers

 

 

 

My second problem is rounding the numbers. Even though i wrote "%.6f" in the format part, it doesn't give me a single decimal value.

 

Thanks in advance

 

Oesen

 

yess.png

Best regards

Oesen
0 Kudos
Message 1 of 9
(3,378 Views)

It looks like you are updating the output file after an event structure so any time the loop iterates, content will be added to the file (if you are using a 2-sec timeout with the event structure, that would explain the updates). I expect this is not the behavior your want. Move the file write action to its own event case (e.g. button: value change) or after the loop terminates.

 

Set Excel number appearance with Format Cell (Ctrl+1) and set decimal places. Remember you are creating a text file (CSV) so look at it in Notepad/Wordpad for proper content. Excel allows different delimiters when reading text files so your semicolon (;) might be causing an issue. Try using a comma instead of semicolon.

 

Good luck.

0 Kudos
Message 2 of 9
(3,369 Views)

Attach your actual VI so we can see what is going on.  Right now you have way too much code that we can't see.

 

A few things I can see:

1.  You have a shift register on that 2-D array.  What are you doing with it in a shift register?  Is it possible you are continually building onto the 2-D array then proceeding to write out the entire array on each iteration?  That's what your Excel file looks like.

 

2.  Your event structure has a "use default if unwired" tunnel for that 2-D wire.  If an event case executes that doesn't output a value to that tunnel, you are effectively clearing the data in the 2-D array and the shift register.

 

3.  Poolmaster, It looks like his data in LabVIEW is using a decimal comma.  So suggesting to use a comma as a separator is going to break things even worse.  Commas for decimal points are a huge problem with programming.  If the European countries who used that standardized on an actual decimal point, these decimal comma problems would go away.  The problem is you are dealing with a combination of LabVIEW, Excel, and the operating system each having their own way of interpreting decimal points.  If they don't all agree in their settings, then the transfer of data between the applications falls apart.  Oesen was already stumbling onto decimal comma problems in another thread he was working in.

0 Kudos
Message 3 of 9
(3,364 Views)
@Raven it'd be better if the Americans followed the international ISO standard and used decimal comma. 😉
G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 4 of 9
(3,352 Views)

Thanks for the answers

 

How can i seperate it, from my shift register ?.

 

 

Best regards

Oesen
0 Kudos
Message 5 of 9
(3,340 Views)

Wire the new data fromt he loop iteration to the Write to File function BEFORE you build it into an array and store it in the shift register.

0 Kudos
Message 6 of 9
(3,333 Views)

Thanks for the help Ravensfan

 

But the "write to spreadsheet box" hasn't a output port, so how do i do that ?

 

I have uploaded my VI

 

 

Best regards

Oesen
0 Kudos
Message 7 of 9
(3,320 Views)
Solution
Accepted by topic author Oesen

@Oesen wrote:

Thanks for the help Ravensfan

 

But the "write to spreadsheet box" hasn't a output port, so how do i do that ?

 

I have uploaded my VI

 

 


I never said anything about the Write to Spreadsheet File having an output port.

 

See the attached VI for the modifications.  It is only the new data from that loop iteration that goes to the Write to Spreadsheet File VI, not the entire built up array from all iterations.  There is a 1-D array input to the Spreadsheet File.

Message 8 of 9
(3,309 Views)

Thanks for the help RavensFan.

 

I was also thinking about that solution, but i didn't do this for some unknown reason :S.

 

Do you know how to handle with that decimal problem ?. I need two decimal numbers, but it rounds the numbers.

 

BTW i also want the event structure to clear the array, when it executes.

 

 

 

Best regards

Oesen
0 Kudos
Message 9 of 9
(3,303 Views)