LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Read specific column in every iteration

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

0 Kudos
Message 1 of 10
(4,789 Views)

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

0 Kudos
Message 2 of 10
(4,762 Views)

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. 

0 Kudos
Message 3 of 10
(4,761 Views)

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

0 Kudos
Message 4 of 10
(4,706 Views)
Try looking at the examples. Read From Spreadsheet is one way. Turn on context help and look at the options.
0 Kudos
Message 5 of 10
(4,701 Views)

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 

  • using Frames, or Sequences, usually because the key LabVIEW concept of data flow (which takes place through the wires) is not clearly understood;
  • having humongous Block Diagrams that take many screens to view, whereas a sub-VI takes a 32-by-32 pixel area on the Block Diagram;
  • using Express VIs and the DAQ Assistant, obscuring the important choices that are being "made for you";
  • using Dynamic Wires (a common wire type used by Express VIs), which further obscures the data flowing on the wires.

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

0 Kudos
Message 6 of 10
(4,696 Views)

Thanks for your comments, I admit that my LV skill is poor, but these types of comments doesn't solve my problem!!!

0 Kudos
Message 7 of 10
(4,686 Views)

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.

0 Kudos
Message 8 of 10
(4,678 Views)

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

0 Kudos
Message 9 of 10
(4,669 Views)

@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.

0 Kudos
Message 10 of 10
(4,655 Views)