LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble extracting data from a previously written file

Solved!
Go to solution

I am trying to extract two arrays from a previously written file, which contains two arrays, seperated by a /t char. The files are saved in this format;

Wavelength(nm):Power(W):

*lambda1**power1*

*lambda2**power2*

...

 

"lambda#" and "power#" are both actually numbers, but I wanted to illustrate that they correlate. 

 

Furthermore, with the extracted data, I would like to write a new file, which uses the information (during another sweep) to calculate a third value (called EQE), which is dependant on the power and current at a given wavelength. So while the VI is reading current per lambda, it should also be able to find out what the power value at said lambda was and calculate the EQE.

 

The VIs I have so far are attached. The third portion of "problem.vi" is enclosed in a while loop, so it repeats a lot of times.

 

Thank you very much

0 Kudos
Message 1 of 13
(3,286 Views)

Ok, so where are you having problems?

 

The first thing I notice is that you should read the first line before reading the rest of the file to get rid of the header.  Secondly, you don't need both index arrays.  The node will expand for you.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 13
(3,281 Views)

Thanks for the reply,it seems like the problem is in the second poriton of the file, where the power and wavelength are extracted from the file. I am not familiar with file I/O so my terms will not be correct. When I have execution highlighted, the wavelength index number seems to get stuck fairly quickly (at say #51) where as the power index continually lower to zero.

 

How would I begin from the second line?

 

Thank you so much again

0 Kudos
Message 3 of 13
(3,274 Views)

MAELV wrote:

How would I begin from the second line?


Use a Read Text File function.  Right-click on it and there will be an option to read lines or characters.  If you set it to read lines and leave the number unwired, it will by default read a single line.  You don't care about the header data, so don't worry about the output unless you want to show it on the front panel for debug reasons.  From there, read the rest of the file as you already have.


@MAELV wrote:

When I have execution highlighted, the wavelength index number seems to get stuck fairly quickly (at say #51) where as the power index continually lower to zero.


I'm not sure what you mean by this.  Can you post an example file as well so I can play around with what you are seeing?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 4 of 13
(3,271 Views)

Yes I will try and get a better description of the problem, its difficult because th emachine on which I am running LabView does not have internet so I have to move everything from there to here

0 Kudos
Message 5 of 13
(3,264 Views)

Hold on, I am going to try some rewriting. I will come back to this thread and ask again when it doesnt work (and I will have a muhc mroe specific and better phrased problem 😉 ) thank you so much!!

0 Kudos
Message 6 of 13
(3,260 Views)

Ok, so I think I know where the problem is. I didn't personally write the vi that I attached, but it seems that the problem is in the while loop just past the "read from text file.vi", I don't really understand what that loop is for or what it does

0 Kudos
Message 7 of 13
(3,251 Views)

So it is definitely not extracting the power portion of the file (which is the second column, or element 1 of a 2-D array)

0 Kudos
Message 8 of 13
(3,246 Views)

The comments state that they are trying to removed the 0s from the arrays.  I think this was due to the header being interpreted as 0.  The loop is flat out wrong and I think it should just be removed now that we read the header away before reading the data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 9 of 13
(3,240 Views)

Ok, but when I remove the loop nothing seems to be extracted 😕 . In your opinion, what is the best way to extract arrays from a text file?

0 Kudos
Message 10 of 13
(3,230 Views)