05-16-2015 06:37 PM - edited 05-16-2015 06:43 PM
Hi,
I'm new in labview, I want LV to read data from a text file. But, I need that every iteration only reads one column of the file. I've attacehed the LV .
I don't have any problem about the row numbers...because I want all of them.
The program has 3 sequence, in first sequence I define a frequeny, and in 2nd part, I read one column from the txt file(the number of the column is the same as the iteration number in 1st sequence), and 3rd part I analyze them...
In 2nd part, I need one column of the txt file to be fed into FFT.vi.
In advance thanks for your help.
Petar
05-16-2015 08:31 PM
Petar,
1. You do not need the sequence structure. LabVIEW uses dataflow to determine the order of execution.
2. Generally you cannot read one column from a file. Files are usually organized by rows. When a 2D array is written to a file the top row is written first, followed by the next row and then the one after that. This is not just LV. Almost every program I know of which stores data in fiels does it this way. Unless your file is huge, it is best to read the entire file at one time then index out the columns as you need them.
3. Insert Into Array is an inefficient way to build an array. Either use autoindexing or Build Array primitive.
4. The for loops in the third frame can be replaced by the Ramp.vi.
5. When you have repeated code as in the third frame, create and use a subVI. Then if you ever need to change that code, you only need to change it in one place. It also makes the block diagram more compact.
6. Diagrams and font panels shoud be kept to the size of one screen. Scrolling around to see what is going on slows productivity and makes debugging very difficult.
Lynn
05-16-2015 08:33 PM
Are you planning to be changing the data while your program is running? If not, it's pretty trivial to do. Read your data once. Create a 2D array with the data. Transpose the 2D array (make the columns rows and vice vesa). Feed the array into a for loop using an auto-indexed tunnel (this will pull off each row one at a time. These are now your original columns. Do your processing.
05-17-2015 02:09 PM
Many thanks for your replies, Would you please give me more explanation? to read, which vi should I use?Also to creat or transpose 2D array...
Thanks
Petar
05-17-2015 02:20 PM
05-17-2015 02:29 PM
There's a great temptation to "dive in" to LabVIEW and start coding (because how difficult could it be, it has pictures ...). This often leads to a lot of Bad Habits, such as
Have you availed yourself of the LabVIEW Tutorials (which will take several hours to view)? Do you know a good LabVIEW programmer (an Instructor, perhaps) who can advise you on LabVIEW Style (see first two points above)?
Bob Schor
05-17-2015 03:17 PM
Thanks for your comments, I admit that my LV skill is poor, but these types of comments doesn't solve my problem!!!
05-17-2015 03:26 PM
The message about using Read from Spreadsheet Array is one that should help you solve your immediate problem. And taking LabVIEW tutorials will help you solve your problems in the long term.
05-17-2015 04:40 PM
You did not specify the exact format of the data in the text file. What numeric format is used for each element? What is used to spearate elements? What is used to separate rows? Is there a header? Are there other non-data elements?
The answer to those questions will determine how to read the file.
Lynn
05-17-2015 06:02 PM
@Petar2015 wrote:
Thanks for your comments, I admit that my LV skill is poor, but these types of comments doesn't solve my problem!!!
Neither does expecting other people to do your work for you. You were given the idea to look at the examples. That handles the file input. If you spent ~5 minutes looking through LabVIEW, I'm sure you could figure out a way to transpose 2D array.
People do you a disservice if they just hand you the answer and you're incredibly dispresectful if you EXPECT them to do so. Show us what you've tried. Show us what you learned from the examples. Do SOMETHING towards your own project.