LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

replace numbers in cols while opening more than 1 file

Huhu...

I need some help, please...
in the first part of the VI i read more files...then in the FOR-L i replace all the zeroes in the 5th col with values of the row before....but this doesn´t work, if the 2nd file already starts with 0...so at this point the prog should take the last non zero value from file before....

if i have.... 247,5....248,3....NEW FILE STARTS....0,00...0,00....273,2....274...0,00...0,00
it should be: 247,5....248,3...248,3..248,3..273,2....274....274....274 .....

I tried to solve that with a local variable, but does not work correctly.
what´s wrong with the non cool local variable? What must i change?

Here is the VI and the example with local variable how i tried....



Greetings
0 Kudos
Message 1 of 16
(3,865 Views)

Hi Leco,

 

Could you post some code please. Is a lot easier to help when looking at what you are trying to do.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 2 of 16
(3,861 Views)

Sorry, now it´s postet 2 times.....something is crazy with this page today....i could not add attachments....

 

here they are.

the zeroes are at end of file 1 and at begin of file 2 (ca. at 200 seconds)

Download All
0 Kudos
Message 3 of 16
(3,855 Views)

Hi Leco,

 

Try this at the end instead:

 

Fill column 5 snippet.png

 

 

Have posted the snippet above in case you dont have LV2009, will post an updated version of your code below.

 

 

Note: you shouldnt normally use the = 0 with doubles but as you are reading from a spreadsheet that have fixed string values of 0 i think that

this should be ok. It worked for the test anyway. Im sure if this is still a problem someone will correct me.

 

Rgs,

 

Lucither

Message Edited by Lucither on 05-06-2010 09:29 AM
------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 4 of 16
(3,811 Views)

Well, a local variable won't "magically" fix an algorithm error. It can actually make things worse by potentially creating a race condition. Smiley Wink

 

In your code off to the right you only need one for-loop. You have the basic idea of what you need to do. See attached modification that works on the 2D array after it's been all read in. You could actually place the loop that does the replacing inside the loop that reads each file as well.

 

Notes:

  • DO NOT USE THE EQUAL FUNCTIONS TO COMPARE FLOATING POINT NUMBERS. Otherwise, you owe me a nickel.
  • You can use the Read From Spreadsheet File to do the same thing you were doing with reading the file and converting the text.
  • I would suggest using a listbox for the file selection - it's more intuitive, and you only need one control instead of 2.


EDIT: Lucither gave you an alternate solution. I had chosen to replace by rows - he did it by element. I was just too lazy this morning to create an optimized program.
Message Edited by smercurio_fc on 05-06-2010 09:33 AM
Message 5 of 16
(3,806 Views)

Lucither wrote:

Hi Leco,

 


Note: you shouldnt normally use the = 0 with doubles but as you are reading from a spreadsheet that have fixed string values of 0 i think that

this should be ok. It worked for the test anyway. Im sure if this is still a problem someone will correct me.


It probably will be OK. But then, I like to play things safe.

0 Kudos
Message 6 of 16
(3,797 Views)

Smercurio,

 

Your absolutely right. Should really practise good habits all the time, wont then bite me in the ass in years to come:

 

Fill column 5 snippet.png

 

Have altered it. Now uses an 'Approx Equals' vi. Have set this accurate to 3 decimal places.

 

Will re-post your updated vi with this vi in a folder also.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 7 of 16
(3,794 Views)
thanks, guys, now i can finish my homework 😉
0 Kudos
Message 8 of 16
(3,766 Views)

lecojon wrote:
thanks, guys, now i can finish my homework 😉

Now I just feel dirty.

0 Kudos
Message 9 of 16
(3,761 Views)

Hi,

 

you feel dirty when you help people? it was this little thing that didn´t work, and you helped me to realize that. where´s the problem?

 

greetings.

0 Kudos
Message 10 of 16
(3,724 Views)