LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Write to spreadsheet is adding a new blank row after each run

I have a VI that is collecting data, and then writing it to a spreadsheet. The problem I am having, is that after each run it will add a new blank row at the top of the spreadsheet. The last run will have the data starting at row 2, row 1 is the name of the part tested, and then the part before that will have the data starting on row 3 part before that starting on row 4, and so on. The interesting thing though is that the name for each part is always on row 1, and it is only the data that is being moved down a row each run. In the snipped the disconnected line is the array of data collected.

0 Kudos
Message 1 of 6
(3,632 Views)

Post your code, not a picture of a tiny piece of your code.

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 2 of 6
(3,613 Views)

Here is a snippet of the state that does the capture and writing, as well as the entire VI.

Download All
0 Kudos
Message 3 of 6
(3,608 Views)

Why are you opening the file and reading into an array, adding in your new row, and then rewriting the entire file every time?

 

Use the Append function of the Write to Delimited spreadsheet vi to write successive rows of data to a file.

 

AppendCapture.PNG

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 6
(3,603 Views)

Also DON'T open and close your VISA session every time your "Step" state runs.

 

Open the VISA session at the start of your program

Pass the VISA reference around the loop and to all of your states using a shift register 

Close the VISA session at the end of your program

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 5 of 6
(3,599 Views)

I actually just realized my mistake and fixed it. I forgot to zero the data array on reset. The reason for opening the file, reading, and adding the new data is that I want the data stored in columns rather than in rows, as it is much easier to read and compare that way.

0 Kudos
Message 6 of 6
(3,588 Views)