LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

read from spreadsheet tries to open two files

Solved!
Go to solution

I want to open several files and combine them. I attempted to make a for loop with variable number of iterations depending on how many files I intend on combining. In the for loop I placed a Read From Spreadsheet. When I run the vi with highlight execution on, it runs perfectly - exactly how I intended. When I run without, it read from spreadsheet always tries to open one more file than the number I told it and subsequently crashes. I can't figure out what is happening because it runs fine when I am trying to debug it.Labview.jpg

Thanks for you help! 

0 Kudos
Message 1 of 5
(2,483 Views)

Please do a little code cleanup.  You have some backwards running wires making your code hard to decipher.

 

What you've shown with a 1 going into the For Loop should open a file for reading one time.  (It will pop up a dialog asking you for the filename.)

 

Then later it will open up 1 file to write out data, (again popping up a dialog asking you for another filename.)

 

Normally, someone saying "it works with highlight execution on, but not normally" is a sure sign they have a race condition due to abuse of local variables.  But I don't see any of that in the code you posted. 

 

If this screenshot doesn't represent what you are really running, then please post a .vi with a couple of example files so we can try out your code to figure out what you are doing.

0 Kudos
Message 2 of 5
(2,471 Views)

Why do you have shift registers in your for loop? The loop is only iterating one time so the updated value is in the shift register is never being used.

 

I'm guessing it is because this is a prototype of your actual code because it doesn't read multiple files, but if not then you don't even need the for loop. And as Ravens said, if it's not your actual code there may be something missing from this that is causing the problem

Message Edited by for(imstuck) on 06-16-2010 09:08 PM
0 Kudos
Message 3 of 5
(2,466 Views)
Solution
Accepted by mattfred

Sorry if it's a little messy - as imstuck said this vi is something that I slapped together quickly to manipulate some data. I made the loop iterate once with a constant to try and eliminate sources of error.

 

I fixed it a little while ago. I had the file I was trying to load open in excel and closing excel fixed the problem. I don't know if this is a common problem with labview (it doesn't happen at all when I have the files open with notepad).  In case someone else comes across this problem, closing the excel document fixed it completely.

0 Kudos
Message 4 of 5
(2,456 Views)
Excel is a program that locks a file when it opens it to prevent other programs from editing it.  Notepad does not lock the file.  It just opens a snapshot of the file at that instant in time.
Message 5 of 5
(2,453 Views)