07-30-2012 10:23 AM
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
Solved! Go to Solution.
07-30-2012 10:44 AM
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.
07-30-2012 11:59 AM
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
07-30-2012 12:06 PM - edited 07-30-2012 12:08 PM
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?
07-30-2012 12:14 PM
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
07-30-2012 12:32 PM
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!!
07-30-2012 01:41 PM
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
07-30-2012 01:53 PM
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)
07-30-2012 02:01 PM
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.
07-30-2012 02:13 PM
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?